aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Krahn <dkrahn@google.com>2019-03-27 09:06:09 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-03-27 09:06:09 -0700
commit732e2109f14ec5accc52c0693890a67d2129f93a (patch)
tree5acf266863308ea4d4c6e226cfd322730ac74e4c
parent3d0cccb29c9431214978290258499d46cc6f7bd4 (diff)
parent07de51c7e8761a870284e9832d82916892800b44 (diff)
downloadepid-sdk-732e2109f14ec5accc52c0693890a67d2129f93a.tar.gz
Update epid_sdk to use Intel IPP crypto library version 2019 update 1, per CVE-2018-12155. am: 10cdf58422
am: 07de51c7e8 Change-Id: Iaed2254185a76e8d78c887d117c0aba8b22ff400
-rw-r--r--Android.bp36
-rw-r--r--METADATA7
-rw-r--r--ext/ipp/LICENSE201
-rw-r--r--ext/ipp/Makefile65
-rw-r--r--ext/ipp/include/ippbase.h188
-rw-r--r--ext/ipp/include/ippcp.h415
-rw-r--r--ext/ipp/include/ippcpdefs.h123
-rw-r--r--ext/ipp/include/ippdefs.h121
-rw-r--r--ext/ipp/include/ipptypes.h977
-rw-r--r--ext/ipp/include/ippversion.h58
-rw-r--r--ext/ipp/ippcp.parts188
-rw-r--r--ext/ipp/sources/include/asmdefs.inc147
-rw-r--r--ext/ipp/sources/include/dispatcher.h321
-rw-r--r--ext/ipp/sources/include/ia_32e.inc4651
-rw-r--r--ext/ipp/sources/include/ia_emm.inc2966
-rw-r--r--ext/ipp/sources/include/ippres.gen267
-rw-r--r--ext/ipp/sources/include/ippver.h65
-rw-r--r--ext/ipp/sources/include/owndefs.h499
-rw-r--r--ext/ipp/sources/ippcp/Makefile31
-rw-r--r--ext/ipp/sources/ippcp/cpinit.c621
-rw-r--r--ext/ipp/sources/ippcp/exports.linux.lib-export1021
-rw-r--r--ext/ipp/sources/ippcp/exports.macosx.lib-export507
-rw-r--r--ext/ipp/sources/ippcp/gsmod_almmontinv.c (renamed from ext/ipp/sources/ippcp/src/gsmodinv.c)146
-rw-r--r--ext/ipp/sources/ippcp/gsmod_almmontinv_ct.c159
-rw-r--r--ext/ipp/sources/ippcp/gsmod_enginegetsize.c91
-rw-r--r--ext/ipp/sources/ippcp/gsmod_engineinit.c131
-rw-r--r--ext/ipp/sources/ippcp/gsmod_getpool.c63
-rw-r--r--ext/ipp/sources/ippcp/gsmod_inv.c93
-rw-r--r--ext/ipp/sources/ippcp/gsmod_montfactor.c76
-rw-r--r--ext/ipp/sources/ippcp/gsmod_montinv.c107
-rw-r--r--ext/ipp/sources/ippcp/gsmod_packctx.c75
-rw-r--r--ext/ipp/sources/ippcp/gsmod_unpackctx.c73
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod.c92
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod.h (renamed from ext/ipp/sources/ippcp/src/gsmodmethod.h)54
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod_dlp.c95
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod_gfp.c94
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod_mont.c95
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethod_rsa.c95
-rw-r--r--ext/ipp/sources/ippcp/gsmodmethodstuff.h (renamed from ext/ipp/sources/ippcp/src/gsmodmethod.c)330
-rw-r--r--ext/ipp/sources/ippcp/gsmodstuff.h (renamed from ext/ipp/sources/ippcp/src/gsmodstuff.h)95
-rw-r--r--ext/ipp/sources/ippcp/gsscramble.c150
-rw-r--r--ext/ipp/sources/ippcp/gsscramble.h75
-rw-r--r--ext/ipp/sources/ippcp/ippcp.def509
-rw-r--r--ext/ipp/sources/ippcp/owncp.h711
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_cbc.h215
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_cmac_stuff.h74
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_ctr_process.h269
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_keys_ni.h74
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_ofb.h72
-rw-r--r--ext/ipp/sources/ippcp/pcpaes_sivstuff.h114
-rw-r--r--ext/ipp/sources/ippcp/pcpaesauthccm.h123
-rw-r--r--ext/ipp/sources/ippcp/pcpaesauthgcm.h204
-rw-r--r--ext/ipp/sources/ippcp/pcpaesm.h72
-rw-r--r--ext/ipp/sources/ippcp/pcpaesmxts.h101
-rw-r--r--ext/ipp/sources/ippcp/pcpaesmxtsstuff.h132
-rw-r--r--ext/ipp/sources/ippcp/pcparcfour.h99
-rw-r--r--ext/ipp/sources/ippcp/pcpbn.h (renamed from ext/ipp/sources/ippcp/src/pcpbn.h)54
-rw-r--r--ext/ipp/sources/ippcp/pcpbn_pack.c74
-rw-r--r--ext/ipp/sources/ippcp/pcpbn_unpack.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpbn_val1.c78
-rw-r--r--ext/ipp/sources/ippcp/pcpbn_val2.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpbn_val3.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithadd.c150
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithcmp.c98
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithcmpz.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithdiv.c125
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithgcd.c298
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithmac.c151
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithminv.c110
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithmod.c127
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithmul.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpbnarithsub.c150
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetext.c96
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetlen.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetoctstr.c90
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetref.c114
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetsize.c93
-rw-r--r--ext/ipp/sources/ippcp/pcpbngetwords.c95
-rw-r--r--ext/ipp/sources/ippcp/pcpbninit.c104
-rw-r--r--ext/ipp/sources/ippcp/pcpbnresource.h72
-rw-r--r--ext/ipp/sources/ippcp/pcpbnresourceca.c144
-rw-r--r--ext/ipp/sources/ippcp/pcpbnsetoctstr.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpbnsetwords.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_add.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_dec.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_div.c200
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_inc.c83
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_muldigit.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_sub.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_arith_submuldigit.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_getoctstr.c100
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_nlz.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32_setoctstr.c97
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32arith.h75
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu32misc.h89
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_add.c97
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_addmuldigit.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_dec.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_gcd.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_inc.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_minv.c187
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_mul_adc.c114
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_sqr_adc.c130
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_sub.c97
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_arith_submuldigit.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_getoctstr.c113
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_lsr.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_msbit.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_nlz.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_ntz.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpbnu_setoctstr.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpbnuarith.h (renamed from ext/ipp/sources/ippcp/src/pcpbnuarith.h)161
-rw-r--r--ext/ipp/sources/ippcp/pcpbnuimpl.h (renamed from ext/ipp/sources/ippcp/src/pcpbnuimpl.h)58
-rw-r--r--ext/ipp/sources/ippcp/pcpbnumisc.h (renamed from ext/ipp/sources/ippcp/src/pcpbnumisc.h)97
-rw-r--r--ext/ipp/sources/ippcp/pcpcmac.h89
-rw-r--r--ext/ipp/sources/ippcp/pcpdes.h118
-rw-r--r--ext/ipp/sources/ippcp/pcpdlp.h144
-rw-r--r--ext/ipp/sources/ippcp/pcpecc_psetdp.c154
-rw-r--r--ext/ipp/sources/ippcp/pcpeccp.h (renamed from ext/ipp/sources/ippcp/src/pcpeccp.h)59
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpaddpoint.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpbindgxytblstd192r1.c84
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpbindgxytblstd224r1.c84
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpbindgxytblstd256r1.c85
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpbindgxytblstd384r1.c85
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpbindgxytblstd521r1.c85
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpcheckpoint.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpcomparepoint.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgenkeyca.c (renamed from ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c)62
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpget.c172
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetorderbitsize.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetpoint.c132
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsize.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd128r1.c72
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd128r2.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd192r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd224r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd256r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd384r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpgetsizestd521r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinit.c106
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd128r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd128r2.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd192r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd224r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd256r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd384r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpinitstd521r1.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpmulpointscalar.c92
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpnegativepoint.c83
-rw-r--r--ext/ipp/sources/ippcp/pcpeccppointgetsize.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpeccppointinit.c92
-rw-r--r--ext/ipp/sources/ippcp/pcpeccppublickeyca.c91
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsecretdhca.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsecretdhcca.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpset.c150
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetkeyca.c (renamed from ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c)60
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetpoint.c133
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetpointatinfinity.c78
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd.c152
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd128r1.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd128r2.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd192r1.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd224r1.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd256r1.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd384r1.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsetstd521r1.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsigndsaca.c221
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsignnrca.c205
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpsignsm2ca.c120
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpstdca.c (renamed from ext/ipp/sources/ippcp/src/pcpeccpstdca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpvalidateca.c116
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpvalidatekeyca.c94
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpverifydsaca.c (renamed from ext/ipp/sources/ippcp/src/pcpeccpverifydsaca.c)66
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpverifynrca.c193
-rw-r--r--ext/ipp/sources/ippcp/pcpeccpverifysm2ca.c196
-rw-r--r--ext/ipp/sources/ippcp/pcpeccresultca.c90
-rw-r--r--ext/ipp/sources/ippcp/pcpecprime.h79
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp.c133
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_exp.c60
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_get.c68
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_getoctstring.c69
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_gfeqnr.c83
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_inv.c59
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_rand.c79
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_set.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_setgfp.c92
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_setoctstring.c74
-rw-r--r--ext/ipp/sources/ippcp/pcpgfp_sqrt.c173
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpadd.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpaddpe.c105
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpbufsize.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpcmpelem.c105
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpconj.c100
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpcpyelem.c95
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec.c84
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_add.c161
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_addaffine.c133
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_baseprod.c100
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_comppont.c126
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_dblpoint.c134
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_getpoint.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_makepoint.c95
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_mul.c138
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_mul1.c79
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_mulbase.c111
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_mulbase1.c83
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_negpoint.c68
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_prod.c172
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_selectp192r1w7.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_selectp224r1w7.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_selectp256r1w7.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_selectp384r1w5.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_selectp521r1w5.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_setpoint.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpec_setuptable.c155
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecaddpoint.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbindstd192r1.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbindstd224r1.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbindstd256r1.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbindstd384r1.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbindstd521r1.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecbufsize.c95
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpeccmppoint.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpeccpypoint.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecdh.c151
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecdhc.c163
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecessm2.h97
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecget.c110
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecgetpoint.c109
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecgetpointoctstring.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecgetpointreg.c133
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecgetsize.c86
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecgetsubgroup.c147
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinit.c146
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd128r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd128r2.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd192r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd224r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd256r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd384r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstd521r1.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecinitstdbn256.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpeckeys.c152
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecmakepoint.c111
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecmulpoint.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecnegpoint.c100
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecpoint.c137
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecpointstuff.c117
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecprivatekey.c121
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecpublickey.c118
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecset.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpoint.c109
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointatinf.c91
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointhash.c177
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointhash_rmf.c173
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointoctstring.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointrand.c159
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetpointreg.c132
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsetsubgroup.c146
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsigndsa.c250
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecsignnr.c229
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecstuff.h (renamed from ext/ipp/sources/ippcp/src/pcpgfpecstuff.h)162
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpectstpoint.c104
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpectstpointinsubgroup.c115
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecverify.c166
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecverifydsa.c201
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpecverifynr.c191
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpelemgetsize.c86
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpeleminit.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpexp.c105
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpgetelem.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpgetelemoctstr.c115
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpgetsize.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpinit.c134
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpinitarbitrary.c108
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpinitfixed.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpinv.c101
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpisunityelem.c108
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpiszeroelem.c98
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod.h86
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_192r1.c (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_192r1.c)101
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_224r1.c (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_224r1.c)103
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_256.c73
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_256.h (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_256.c)103
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_256bn.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_256r1.c (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_256r1.c)94
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_384r1.c (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_384r1.c)84
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_521r1.c (renamed from ext/ipp/sources/ippcp/src/pcpgfpmethod_521r1.c)87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmethod_com.c70
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmul.c103
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmulexp.c158
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpmulpe.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpneg.c97
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelem.c113
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelemhash.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelemhashrmf.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelemoctstr.c120
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelemrand.c97
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsetelemreg.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsqr.c98
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsqrt.c103
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpstuff.h (renamed from ext/ipp/sources/ippcp/src/pcpgfpstuff.h)118
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsub.c100
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpsubpe.c104
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx.c94
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_add_gfe.c66
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_conj.c65
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_exp.c217
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_get.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_getpolyterm.c59
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_inv.c246
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_mul_gfe.c71
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_multiexp.c204
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_neg.c69
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_rand.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_set.c79
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_setpolyterm.c59
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpx_sub_gfe.c66
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxgetsize.c109
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxinit.c133
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxinitbinomial.c117
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom.c143
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom2.c213
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom3.c217
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom3_epid2.c276
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.c296
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.h122
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_binom_mulc.h80
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com.c96
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com.h76
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_add.c68
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_decode.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_div2.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_encode.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul2.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul3.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_neg.c67
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_sqr.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxmethod_com_sub.c68
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxstuff.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpgfpxstuff.h (renamed from ext/ipp/sources/ippcp/src/pcpgfpxstuff.h)57
-rw-r--r--ext/ipp/sources/ippcp/pcphash.h (renamed from ext/ipp/sources/ippcp/src/pcphash.h)60
-rw-r--r--ext/ipp/sources/ippcp/pcphash_digest.c149
-rw-r--r--ext/ipp/sources/ippcp/pcphash_func.h133
-rw-r--r--ext/ipp/sources/ippcp/pcphash_init.c84
-rw-r--r--ext/ipp/sources/ippcp/pcphash_reinit.c84
-rw-r--r--ext/ipp/sources/ippcp/pcphash_rmf.h77
-rw-r--r--ext/ipp/sources/ippcp/pcphashca_rmf.c83
-rw-r--r--ext/ipp/sources/ippcp/pcphashcnt.c (renamed from ext/ipp/sources/ippcp/src/pcphashcnt.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcphashduplicate.c88
-rw-r--r--ext/ipp/sources/ippcp/pcphashduplicate_rmf.c90
-rw-r--r--ext/ipp/sources/ippcp/pcphashfinal.c91
-rw-r--r--ext/ipp/sources/ippcp/pcphashfinal_rmf.c100
-rw-r--r--ext/ipp/sources/ippcp/pcphashgetsize.c78
-rw-r--r--ext/ipp/sources/ippcp/pcphashgetsize_rmf.c78
-rw-r--r--ext/ipp/sources/ippcp/pcphashgettag.c92
-rw-r--r--ext/ipp/sources/ippcp/pcphashgettag_rmf.c101
-rw-r--r--ext/ipp/sources/ippcp/pcphashinit.c91
-rw-r--r--ext/ipp/sources/ippcp/pcphashinit_rmf.c84
-rw-r--r--ext/ipp/sources/ippcp/pcphashmd5px.c233
-rw-r--r--ext/ipp/sources/ippcp/pcphashmessage.c168
-rw-r--r--ext/ipp/sources/ippcp/pcphashmessage_rmf.c109
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_md5.c84
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_rmf.h68
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha1.c81
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha1_ni.c86
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha1_tt.c90
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha224.c82
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha224_ni.c87
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha224_tt.c90
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha256.c81
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha256_ni.c86
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha256_tt.c90
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha384.c82
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha512.c82
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha512_224.c82
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sha512_256.c82
-rw-r--r--ext/ipp/sources/ippcp/pcphashmethod_sm3.c81
-rw-r--r--ext/ipp/sources/ippcp/pcphashpack.c87
-rw-r--r--ext/ipp/sources/ippcp/pcphashpack_rmf.c87
-rw-r--r--ext/ipp/sources/ippcp/pcphashsha1px.c (renamed from ext/ipp/sources/ippcp/src/pcphashsha1px.c)57
-rw-r--r--ext/ipp/sources/ippcp/pcphashsha256px.c (renamed from ext/ipp/sources/ippcp/src/pcphashsha256px.c)59
-rw-r--r--ext/ipp/sources/ippcp/pcphashsha512px.c (renamed from ext/ipp/sources/ippcp/src/pcphashsha512px.c)59
-rw-r--r--ext/ipp/sources/ippcp/pcphashsm3px.c366
-rw-r--r--ext/ipp/sources/ippcp/pcphashunpack.c80
-rw-r--r--ext/ipp/sources/ippcp/pcphashunpack_rmf.c80
-rw-r--r--ext/ipp/sources/ippcp/pcphashupdate.c160
-rw-r--r--ext/ipp/sources/ippcp/pcphashupdate_rmf.c139
-rw-r--r--ext/ipp/sources/ippcp/pcphmac.h74
-rw-r--r--ext/ipp/sources/ippcp/pcphmac_rmf.h64
-rw-r--r--ext/ipp/sources/ippcp/pcpmask_ct.h141
-rw-r--r--ext/ipp/sources/ippcp/pcpmd5stuff.h124
-rw-r--r--ext/ipp/sources/ippcp/pcpmgf1ca_rmf.c122
-rw-r--r--ext/ipp/sources/ippcp/pcpmgf2ca_rmf.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_exp_bufsize.h74
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_expbinbnu.c144
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_expsafebinary.c (renamed from ext/ipp/sources/ippcp/src/pcpmontexpbinca.c)243
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_getsize.c85
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_init.c87
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_multiexp_fast.c112
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_multiexpinitarray.c113
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_packctx.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_set.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpmont_unpackctx.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpmontexp.c110
-rw-r--r--ext/ipp/sources/ippcp/pcpmontexp_winsize.c103
-rw-r--r--ext/ipp/sources/ippcp/pcpmontform.c112
-rw-r--r--ext/ipp/sources/ippcp/pcpmontget.c90
-rw-r--r--ext/ipp/sources/ippcp/pcpmontgetsize.c85
-rw-r--r--ext/ipp/sources/ippcp/pcpmontgomery.h (renamed from ext/ipp/sources/ippcp/src/pcpmontgomery.h)60
-rw-r--r--ext/ipp/sources/ippcp/pcpmontinit.c84
-rw-r--r--ext/ipp/sources/ippcp/pcpmontmul.c123
-rw-r--r--ext/ipp/sources/ippcp/pcpmontred.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpmontred.h80
-rw-r--r--ext/ipp/sources/ippcp/pcpmontset.c91
-rw-r--r--ext/ipp/sources/ippcp/pcpname.h72
-rw-r--r--ext/ipp/sources/ippcp/pcpngmontexpstuff.h188
-rw-r--r--ext/ipp/sources/ippcp/pcpngmontexpstuff_avx2.h142
-rw-r--r--ext/ipp/sources/ippcp/pcpngmontexpstuff_avx512.h122
-rw-r--r--ext/ipp/sources/ippcp/pcpngmontexpstuff_sse2.h120
-rw-r--r--ext/ipp/sources/ippcp/pcpngrsa.h145
-rw-r--r--ext/ipp/sources/ippcp/pcpngrsamethod.h97
-rw-r--r--ext/ipp/sources/ippcp/pcpp192r1precomca.c (renamed from ext/ipp/sources/ippcp/src/pcpp192r1precomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpp224r1precomca.c (renamed from ext/ipp/sources/ippcp/src/pcpp224r1precomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpp256r1precomca.c (renamed from ext/ipp/sources/ippcp/src/pcpp256r1precomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpp384r1precomca.c (renamed from ext/ipp/sources/ippcp/src/pcpp384r1precomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpp521r1precomca.c (renamed from ext/ipp/sources/ippcp/src/pcpp521r1precomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpprime_isco.h86
-rw-r--r--ext/ipp/sources/ippcp/pcpprime_isprob.h143
-rw-r--r--ext/ipp/sources/ippcp/pcpprimeg.h117
-rw-r--r--ext/ipp/sources/ippcp/pcpprng.h95
-rw-r--r--ext/ipp/sources/ippcp/pcpprng_gen.c171
-rw-r--r--ext/ipp/sources/ippcp/pcpprng_genhw.h130
-rw-r--r--ext/ipp/sources/ippcp/pcpprngen_bn.c114
-rw-r--r--ext/ipp/sources/ippcp/pcpprngen_pattern.c78
-rw-r--r--ext/ipp/sources/ippcp/pcpprngen_range.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpprngenca.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpprngenhw_bn.c117
-rw-r--r--ext/ipp/sources/ippcp/pcpprngenhwca.c106
-rw-r--r--ext/ipp/sources/ippcp/pcpprnggetseed.c92
-rw-r--r--ext/ipp/sources/ippcp/pcpprnggetsize.c79
-rw-r--r--ext/ipp/sources/ippcp/pcpprnginitca.c108
-rw-r--r--ext/ipp/sources/ippcp/pcpprngsetaugment.c98
-rw-r--r--ext/ipp/sources/ippcp/pcpprngsetca.c94
-rw-r--r--ext/ipp/sources/ippcp/pcpprngsetmodulus.c92
-rw-r--r--ext/ipp/sources/ippcp/pcpprngsetseed.c97
-rw-r--r--ext/ipp/sources/ippcp/pcprij.h255
-rw-r--r--ext/ipp/sources/ippcp/pcprij128safe.h142
-rw-r--r--ext/ipp/sources/ippcp/pcprij128safe2.h97
-rw-r--r--ext/ipp/sources/ippcp/pcprijtables.h220
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_emsa_pkcs1v15.h80
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_generatesing_pkcs1v15.h108
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_getdefmeth_priv.h74
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_getdefmeth_pub.h73
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_pkcs1c15_data.h83
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_sizeof_privkey1.h61
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_sizeof_privkey2.h72
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_sizeof_pubkey.h62
-rw-r--r--ext/ipp/sources/ippcp/pcprsa_verifysing_pkcs1v15.h96
-rw-r--r--ext/ipp/sources/ippcp/pcpscramble.h192
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1duplicate.c90
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1final.c99
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1getsize.c79
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1gettag.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1init.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1messagedigest.c121
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1pack.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1stuff.h110
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1unpack.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpsha1update.c146
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224duplicate.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224final.c102
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224getsize.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224gettag.c106
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224init.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224messagedigest.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224pack.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224unpack.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpsha224update.c80
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256_messagedigest.c110
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256ca.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256duplicate.c91
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256final.c103
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256getsize.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256gettag.c105
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256init.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256messagedigest.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256pack.c82
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256stuff.h200
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256unpack.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpsha256update.c146
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384duplicate.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384final.c104
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384getsize.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384gettag.c106
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384init.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384messagedigest.c89
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384pack.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384unpack.c77
-rw-r--r--ext/ipp/sources/ippcp/pcpsha384update.c80
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512_init.c76
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512_messagedigest.c94
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512duplicate.c91
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512final.c105
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512getsize.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512gettag.c107
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512init.c75
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512messagedigest.c88
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512pack.c83
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512stuff.h225
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512unpack.c81
-rw-r--r--ext/ipp/sources/ippcp/pcpsha512update.c141
-rw-r--r--ext/ipp/sources/ippcp/pcpshsmgfca.c136
-rw-r--r--ext/ipp/sources/ippcp/pcpsm2pprecomca.c (renamed from ext/ipp/sources/ippcp/src/pcpsm2pprecomca.c)54
-rw-r--r--ext/ipp/sources/ippcp/pcpsm3stuff.h119
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4.h201
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4_decrypt_cbc.h121
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4_encrypt_cbc.h108
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4_process_ofb8.h107
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4authccm.h113
-rw-r--r--ext/ipp/sources/ippcp/pcpsms4ecby8cn.h141
-rw-r--r--ext/ipp/sources/ippcp/pcptool.h (renamed from ext/ipp/sources/ippcp/src/pcptool.h)94
-rw-r--r--ext/ipp/sources/ippcp/pcptrngenhwca.c226
-rw-r--r--ext/ipp/sources/ippcp/pcpvariant.h (renamed from ext/ipp/sources/ippcp/src/pcpvariant.h)83
-rw-r--r--ext/ipp/sources/ippcp/pcpver.c118
-rw-r--r--ext/ipp/sources/ippcp/pcpver.h54
-rw-r--r--ext/ipp/sources/ippcp/pcpver.rc53
-rw-r--r--ext/ipp/sources/ippcp/src/gsmodstuff.c168
-rw-r--r--ext/ipp/sources/ippcp/src/gsscramble.c127
-rw-r--r--ext/ipp/sources/ippcp/src/gsscramble.h71
-rw-r--r--ext/ipp/sources/ippcp/src/owncp.h203
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnca.c1297
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnsetca.c117
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnu32arith.c280
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnu32arith.h51
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnu32misc.c126
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnu32misc.h65
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnuarith.c538
-rw-r--r--ext/ipp/sources/ippcp/src/pcpbnumisc.c225
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp128r1r2dpca.c75
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp192r1dpca.c63
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp224r1dpca.c63
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp256r1dpca.c63
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp384r1dpca.c64
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccp521r1dpca.c63
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccpdpca.c453
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccpinitca.c251
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccppointca.c105
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccppointopca.c397
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c194
-rw-r--r--ext/ipp/sources/ippcp/src/pcpeccpsm2dpca.c64
-rw-r--r--ext/ipp/sources/ippcp/src/pcpecprime.h55
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfp.c1165
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpec.c881
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecdh.c229
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpeckeys.c257
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecpoint.c643
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecpointstuff.c1243
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecsigndsa.c331
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecsignnr.c314
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpecsignsm2.c349
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpmethod.h62
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpmethod_com.c37
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpmethod_sm2.c179
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpstuff.c296
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpx.c250
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom.c442
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom_epid2.c498
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.c311
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.h52
-rw-r--r--ext/ipp/sources/ippcp/src/pcpgfpxstuff.c722
-rw-r--r--ext/ipp/sources/ippcp/src/pcphash_rmf.h51
-rw-r--r--ext/ipp/sources/ippcp/src/pcphashca.c683
-rw-r--r--ext/ipp/sources/ippcp/src/pcphashca_rmf.c437
-rw-r--r--ext/ipp/sources/ippcp/src/pcphashmethod_rmf.h44
-rw-r--r--ext/ipp/sources/ippcp/src/pcpmontgomeryca.c424
-rw-r--r--ext/ipp/sources/ippcp/src/pcpmontred.c75
-rw-r--r--ext/ipp/sources/ippcp/src/pcpmontred.h56
-rw-r--r--ext/ipp/sources/ippcp/src/pcpmulbnukara.h87
-rw-r--r--ext/ipp/sources/ippcp/src/pcpprng.h71
-rw-r--r--ext/ipp/sources/ippcp/src/pcpprngenca.c296
-rw-r--r--ext/ipp/sources/ippcp/src/pcpprnginitca.c111
-rw-r--r--ext/ipp/sources/ippcp/src/pcpprngsetca.c239
-rw-r--r--ext/ipp/sources/ippcp/src/pcpsha256ca.c814
585 files changed, 65198 insertions, 20158 deletions
diff --git a/Android.bp b/Android.bp
index 27e94c1..be71243 100644
--- a/Android.bp
+++ b/Android.bp
@@ -24,13 +24,45 @@ cc_library {
name: "libippcp",
defaults: ["epid_cflags"],
srcs: [
- "ext/ipp/sources/ippcp/src/*.c",
+ "ext/ipp/sources/ippcp/*.c",
+ ],
+ exclude_srcs: [
+ "ext/ipp/sources/ippcp/*md5.c",
+ "ext/ipp/sources/ippcp/*sm2*.c",
+ "ext/ipp/sources/ippcp/*sm3.c",
+ "ext/ipp/sources/ippcp/cpinit.c",
+ "ext/ipp/sources/ippcp/pcpaes*.c",
+ "ext/ipp/sources/ippcp/pcparcfour*.c",
+ "ext/ipp/sources/ippcp/pcpdes*.c",
+ "ext/ipp/sources/ippcp/pcpdlp*.c",
+ "ext/ipp/sources/ippcp/pcphmac*.c",
+ "ext/ipp/sources/ippcp/pcpmain.c",
+ "ext/ipp/sources/ippcp/pcpmd5*.c",
+ "ext/ipp/sources/ippcp/pcpmont_expbinbnu_sscm.c",
+ "ext/ipp/sources/ippcp/pcpmont_expwinbnu.c",
+ "ext/ipp/sources/ippcp/pcpmont_expwinbnu_sscm.c",
+ "ext/ipp/sources/ippcp/pcpng*.c",
+ "ext/ipp/sources/ippcp/pcpprime*.c",
+ "ext/ipp/sources/ippcp/pcprij*.c",
+ "ext/ipp/sources/ippcp/pcprsa*.c",
+ "ext/ipp/sources/ippcp/pcpsha1*.c",
+ "ext/ipp/sources/ippcp/pcpsm3*.c",
+ "ext/ipp/sources/ippcp/pcpsms4*.c",
+ "ext/ipp/sources/ippcp/pcptdes*.c",
],
cflags: [
- "-D_IPP_v50_",
"-D_IPP_DEBUG",
+ "-D_IPP_C99",
+ "-D_IPP_v50_",
+ "-D_PX",
+ "-D_DISABLE_ECP_SM2_",
+ "-D_DISABLE_ALG_SHA224_",
+ "-D_DISABLE_ALG_SHA512_224_",
"-D_DISABLE_ALG_MD5_",
"-D_DISABLE_ALG_SM3_",
+ "-Wno-unused-function",
+ "-Wno-date-time",
+ "-Wno-#pragma-messages",
],
local_include_dirs: [
"ext/ipp/sources/ippcp/",
diff --git a/METADATA b/METADATA
index b7e370f..27a7b91 100644
--- a/METADATA
+++ b/METADATA
@@ -11,6 +11,11 @@ third_party {
type: GIT
value: "https://github.com/Intel-EPID-SDK/epid-sdk.git"
}
+ url {
+ type: GIT
+ value: "https://github.com/Intel-EPID-SDK/epid-sdk/tree/v7.0.1/ext/ipp-crypto"
+ }
version: "6.0.1"
- last_upgrade_date { year: 2018 month: 6 day: 14 }
+ last_upgrade_date { year: 2019 month: 3 day: 26 }
+ local_modifications: "Upgraded IPP library to 2019 update 1 for CVE-2018-12155"
}
diff --git a/ext/ipp/LICENSE b/ext/ipp/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/ext/ipp/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ext/ipp/Makefile b/ext/ipp/Makefile
new file mode 100644
index 0000000..c7d6855
--- /dev/null
+++ b/ext/ipp/Makefile
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+
+API_INCLUDE_DIR = ./include
+SRC_INCLUDE_DIR = ./sources/include
+LIB_INSTALL_DIR = $(epidinstalldir)/lib/posix-$(ARCH)/
+
+PCP_INCLUDE_DIR = ./sources/ippcp
+PCP_SRC = $(wildcard ./sources/ippcp/*.c)
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcparcfour*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out ./sources/ippcp/pcpmain.c, $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/*sm2.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpsha1ca.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpaes*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpdes*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpdlp*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcphmac*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpmd5*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpng*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpprime*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcprij*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcprsa*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpsm3*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcpsms4*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out $(wildcard ./sources/ippcp/pcptdes*.c), $(PCP_SRC))
+PCP_SRC := $(filter-out ./sources/ippcp/pcpmont_expbinbnu_sscm.c, $(PCP_SRC))
+PCP_SRC := $(filter-out ./sources/ippcp/pcpmont_expwinbnu.c, $(PCP_SRC))
+PCP_SRC := $(filter-out ./sources/ippcp/pcpmont_expwinbnu_sscm.c, $(PCP_SRC))
+
+PCP_OBJ = $(PCP_SRC:.c=.o)
+PCP_LIB = ./sources/ippcp/libippcp.a
+
+ifeq ($(ARCH), x86)
+ CFLAGS += -D_ARCH_IA32
+else
+ CFLAGS += -D_ARCH_EM64T
+endif
+CFLAGS += -D_IPP_DEBUG
+CFLAGS += -D_IPP_DEBUG
+CFLAGS += -D_IPP_C99
+CFLAGS += -D_IPP_v50_
+CFLAGS += -D_PX
+CFLAGS += -D_ABL_
+CFLAGS += -D_DISABLE_ECP_SM2_
+CFLAGS += -D_DISABLE_ALG_SHA224_
+CFLAGS += -D_DISABLE_ALG_SHA512_224_
+CFLAGS += -D_DISABLE_ALG_MD5_
+CFLAGS += -D_DISABLE_ALG_SM3_
+
+$(PCP_OBJ): %.o: %.c
+ $(CC) $(CFLAGS) $(IPP_FLAGS) -I$(API_INCLUDE_DIR) -I$(SRC_INCLUDE_DIR) -I$(PCP_INCLUDE_DIR) -c -o $@ $<
+
+$(PCP_LIB): $(PCP_OBJ)
+ $(AR) rc $@ $^
+ $(RANLIB) $@
+
+build: all
+
+all: $(PCP_LIB)
+
+install:
+ mkdir -p '$(LIB_INSTALL_DIR)'
+ cp $(PCP_LIB) '$(LIB_INSTALL_DIR)'
+
+clean:
+ rm -f $(PCP_OBJ) $(PCP_LIB)
diff --git a/ext/ipp/include/ippbase.h b/ext/ipp/include/ippbase.h
deleted file mode 100644
index d068421..0000000
--- a/ext/ipp/include/ippbase.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
-// Basic Types and Macro Definitions
-//
-//
-*/
-
-
-#ifndef IPPBASE_H__
-#define IPPBASE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define IPP_STDCALL __stdcall
- #define IPP_CDECL __cdecl
- #define IPP_INT64 __int64
- #define IPP_UINT64 unsigned __int64
-#else
- #define IPP_STDCALL
- #define IPP_CDECL
- #define IPP_INT64 long long
- #define IPP_UINT64 unsigned long long
-#endif
-
-#define IPP_PI ( 3.14159265358979323846 ) /* ANSI C does not support M_PI */
-#define IPP_2PI ( 6.28318530717958647692 ) /* 2*pi */
-#define IPP_PI2 ( 1.57079632679489661923 ) /* pi/2 */
-#define IPP_PI4 ( 0.78539816339744830961 ) /* pi/4 */
-#define IPP_PI180 ( 0.01745329251994329577 ) /* pi/180 */
-#define IPP_RPI ( 0.31830988618379067154 ) /* 1/pi */
-#define IPP_SQRT2 ( 1.41421356237309504880 ) /* sqrt(2) */
-#define IPP_SQRT3 ( 1.73205080756887729353 ) /* sqrt(3) */
-#define IPP_LN2 ( 0.69314718055994530942 ) /* ln(2) */
-#define IPP_LN3 ( 1.09861228866810969139 ) /* ln(3) */
-#define IPP_E ( 2.71828182845904523536 ) /* e */
-#define IPP_RE ( 0.36787944117144232159 ) /* 1/e */
-#define IPP_EPS23 ( 1.19209289e-07f )
-#define IPP_EPS52 ( 2.2204460492503131e-016 )
-
-#define IPP_MAX_8U ( 0xFF )
-#define IPP_MAX_16U ( 0xFFFF )
-#define IPP_MAX_32U ( 0xFFFFFFFF )
-#define IPP_MIN_8U ( 0 )
-#define IPP_MIN_16U ( 0 )
-#define IPP_MIN_32U ( 0 )
-#define IPP_MIN_8S (-128 )
-#define IPP_MAX_8S ( 127 )
-#define IPP_MIN_16S (-32768 )
-#define IPP_MAX_16S ( 32767 )
-#define IPP_MIN_32S (-2147483647 - 1 )
-#define IPP_MAX_32S ( 2147483647 )
-#define IPP_MIN_64U ( 0 )
-
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define IPP_MAX_64S ( 9223372036854775807i64 )
- #define IPP_MIN_64S (-9223372036854775807i64 - 1 )
- #define IPP_MAX_64U ( 0xffffffffffffffffL ) /* 18446744073709551615 */
-#else
- #define IPP_MAX_64S ( 9223372036854775807LL )
- #define IPP_MIN_64S (-9223372036854775807LL - 1 )
- #define IPP_MAX_64U ( 0xffffffffffffffffLL ) /* 18446744073709551615 */
-#endif
-
-#define IPP_MINABS_32F ( 1.175494351e-38f )
-#define IPP_MAXABS_32F ( 3.402823466e+38f )
-#define IPP_EPS_32F ( 1.192092890e-07f )
-#define IPP_MINABS_64F ( 2.2250738585072014e-308 )
-#define IPP_MAXABS_64F ( 1.7976931348623158e+308 )
-#define IPP_EPS_64F ( 2.2204460492503131e-016 )
-
-#define IPP_MAX( a, b ) ( ((a) > (b)) ? (a) : (b) )
-#define IPP_MIN( a, b ) ( ((a) < (b)) ? (a) : (b) )
-
-#define IPP_ABS( a ) ( ((a) < 0) ? (-(a)) : (a) )
-
-typedef struct {
- int major; /* e.g. 1 */
- int minor; /* e.g. 2 */
- int majorBuild; /* e.g. 3 */
- int build; /* e.g. 10, always >= majorBuild */
- char targetCpu[4]; /* corresponding to Intel(R) processor */
- const char* Name; /* e.g. "ippsw7" */
- const char* Version; /* e.g. "v1.2 Beta" */
- const char* BuildDate; /* e.g. "Jul 20 99" */
-} IppLibraryVersion;
-
-typedef unsigned char Ipp8u;
-typedef unsigned short Ipp16u;
-typedef unsigned int Ipp32u;
-typedef signed char Ipp8s;
-typedef signed short Ipp16s;
-typedef signed int Ipp32s;
-typedef float Ipp32f;
-typedef IPP_INT64 Ipp64s;
-typedef IPP_UINT64 Ipp64u;
-typedef double Ipp64f;
-typedef Ipp16s Ipp16f;
-
-typedef struct {
- Ipp8s re;
- Ipp8s im;
-} Ipp8sc;
-
-typedef struct {
- Ipp16s re;
- Ipp16s im;
-} Ipp16sc;
-
-typedef struct {
- Ipp16u re;
- Ipp16u im;
-} Ipp16uc;
-
-typedef struct {
- Ipp32s re;
- Ipp32s im;
-} Ipp32sc;
-
-typedef struct {
- Ipp32f re;
- Ipp32f im;
-} Ipp32fc;
-
-typedef struct {
- Ipp64s re;
- Ipp64s im;
-} Ipp64sc;
-
-typedef struct {
- Ipp64f re;
- Ipp64f im;
-} Ipp64fc;
-
-typedef enum {
- ippUndef = -1,
- ipp1u = 0,
- ipp8u = 1,
- ipp8uc = 2,
- ipp8s = 3,
- ipp8sc = 4,
- ipp16u = 5,
- ipp16uc = 6,
- ipp16s = 7,
- ipp16sc = 8,
- ipp32u = 9,
- ipp32uc = 10,
- ipp32s = 11,
- ipp32sc = 12,
- ipp32f = 13,
- ipp32fc = 14,
- ipp64u = 15,
- ipp64uc = 16,
- ipp64s = 17,
- ipp64sc = 18,
- ipp64f = 19,
- ipp64fc = 20
-} IppDataType;
-
-typedef enum {
- ippFalse = 0,
- ippTrue = 1
-} IppBool;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IPPBASE_H__ */
-
diff --git a/ext/ipp/include/ippcp.h b/ext/ipp/include/ippcp.h
index fe41815..af67db0 100644
--- a/ext/ipp/include/ippcp.h
+++ b/ext/ipp/include/ippcp.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
@@ -71,27 +95,27 @@ IPPAPI(IppStatus, ippsDESInit,(const Ipp8u* pKey, IppsDESSpec* pCtx))
IPPAPI(IppStatus, ippsDESPack,(const IppsDESSpec* pCtx, Ipp8u* pBuffer))
IPPAPI(IppStatus, ippsDESUnpack,(const Ipp8u* pBuffer, IppsDESSpec* pCtx))
-IPPAPI(IppStatus, ippsTDESEncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int length,
+IPPAPI(IppStatus, ippsTDESEncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
IppsCPPadding padding))
-IPPAPI(IppStatus, ippsTDESDecryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int length,
+IPPAPI(IppStatus, ippsTDESDecryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
IppsCPPadding padding))
-IPPAPI(IppStatus, ippsTDESEncryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int length,
+IPPAPI(IppStatus, ippsTDESEncryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
const Ipp8u* pIV,
IppsCPPadding padding))
-IPPAPI(IppStatus, ippsTDESDecryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int length,
+IPPAPI(IppStatus, ippsTDESDecryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
const Ipp8u* pIV,
IppsCPPadding padding))
-IPPAPI(IppStatus, ippsTDESEncryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, int cfbBlkSize,
+IPPAPI(IppStatus, ippsTDESEncryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
const Ipp8u* pIV,
IppsCPPadding padding))
-IPPAPI(IppStatus, ippsTDESDecryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, int cfbBlkSize,
+IPPAPI(IppStatus, ippsTDESDecryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize,
const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3,
const Ipp8u* pIV,
IppsCPPadding padding))
@@ -123,7 +147,7 @@ IPPAPI(IppStatus, ippsAESGetSize,(int *pSize))
IPPAPI(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx, int ctxSize))
IPPAPI(IppStatus, ippsAESSetKey,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx))
-IPPAPI(IppStatus, ippsAESPack,(const IppsAESSpec* pCtx, Ipp8u* pBuffer, int buffSize))
+IPPAPI(IppStatus, ippsAESPack,(const IppsAESSpec* pCtx, Ipp8u* pBuffer, int bufSize))
IPPAPI(IppStatus, ippsAESUnpack,(const Ipp8u* pBuffer, IppsAESSpec* pCtx, int ctxSize))
IPPAPI(IppStatus, ippsAESEncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
@@ -263,15 +287,15 @@ IPPAPI(IppStatus, ippsSMS4_CCMGetTag,(Ipp8u* pTag, int tagLen, const IppsSMS4_CC
/* AES-CCM */
IPPAPI(IppStatus, ippsAES_CCMGetSize,(int* pSize))
-IPPAPI(IppStatus, ippsAES_CCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_CCMState* pCtx, int ctxSize))
+IPPAPI(IppStatus, ippsAES_CCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_CCMState* pState, int ctxSize))
-IPPAPI(IppStatus, ippsAES_CCMMessageLen,(Ipp64u msgLen, IppsAES_CCMState* pCtx))
-IPPAPI(IppStatus, ippsAES_CCMTagLen,(int tagLen, IppsAES_CCMState* pCtx))
+IPPAPI(IppStatus, ippsAES_CCMMessageLen,(Ipp64u msgLen, IppsAES_CCMState* pState))
+IPPAPI(IppStatus, ippsAES_CCMTagLen,(int tagLen, IppsAES_CCMState* pState))
-IPPAPI(IppStatus, ippsAES_CCMStart,(const Ipp8u* pIV, int ivLen, const Ipp8u* pAD, int adLen, IppsAES_CCMState* pCtx))
-IPPAPI(IppStatus, ippsAES_CCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pCtx))
-IPPAPI(IppStatus, ippsAES_CCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pCtx))
-IPPAPI(IppStatus, ippsAES_CCMGetTag,(Ipp8u* pTag, int tagLen, const IppsAES_CCMState* pCtx))
+IPPAPI(IppStatus, ippsAES_CCMStart,(const Ipp8u* pIV, int ivLen, const Ipp8u* pAD, int adLen, IppsAES_CCMState* pState))
+IPPAPI(IppStatus, ippsAES_CCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pState))
+IPPAPI(IppStatus, ippsAES_CCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pState))
+IPPAPI(IppStatus, ippsAES_CCMGetTag,(Ipp8u* pTag, int tagLen, const IppsAES_CCMState* pState))
/* AES-GCM */
IPPAPI(IppStatus, ippsAES_GCMGetSize,(int * pSize))
@@ -331,16 +355,24 @@ IPPAPI(IppStatus, ippsAES_CMACGetTag,(Ipp8u* pMD, int mdLen, const IppsAES_CMACS
// RC4 Stream Ciphers
// =========================================================
*/
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourCheckKey, (const Ipp8u *pKey, int keyLen, IppBool* pIsWeak))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourGetSize, (int* pSize))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourInit, (const Ipp8u *pKey, int keyLen, IppsARCFourState *pCtx))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourReset, (IppsARCFourState* pCtx))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourPack,(const IppsARCFourState* pCtx, Ipp8u* pBuffer))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourUnpack,(const Ipp8u* pBuffer, IppsARCFourState* pCtx))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourEncrypt, (const Ipp8u *pSrc, Ipp8u *pDst, int length, IppsARCFourState *pCtx))
+IPP_DEPRECATED("is deprecated. This function is obsolete and will be removed in one of the future IPP releases") \
IPPAPI(IppStatus, ippsARCFourDecrypt, (const Ipp8u *pSrc, Ipp8u *pDst, int length, IppsARCFourState *pCtx))
@@ -352,106 +384,106 @@ IPPAPI(IppStatus, ippsARCFourDecrypt, (const Ipp8u *pSrc, Ipp8u *pDst, int lengt
/* SHA1 Hash Primitives */
IPPAPI(IppStatus, ippsSHA1GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSHA1Init,(IppsSHA1State* pCtx))
-IPPAPI(IppStatus, ippsSHA1Duplicate,(const IppsSHA1State* pSrcCtx, IppsSHA1State* pDstCtx))
+IPPAPI(IppStatus, ippsSHA1Init,(IppsSHA1State* pState))
+IPPAPI(IppStatus, ippsSHA1Duplicate,(const IppsSHA1State* pSrcState, IppsSHA1State* pDstState))
-IPPAPI(IppStatus, ippsSHA1Pack,(const IppsSHA1State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSHA1Unpack,(const Ipp8u* pBuffer, IppsSHA1State* pCtx))
+IPPAPI(IppStatus, ippsSHA1Pack,(const IppsSHA1State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSHA1Unpack,(const Ipp8u* pBuffer, IppsSHA1State* pState))
-IPPAPI(IppStatus, ippsSHA1Update,(const Ipp8u* pSrc, int len, IppsSHA1State* pCtx))
-IPPAPI(IppStatus, ippsSHA1GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA1State* pCtx))
-IPPAPI(IppStatus, ippsSHA1Final,(Ipp8u* pMD, IppsSHA1State* pCtx))
+IPPAPI(IppStatus, ippsSHA1Update,(const Ipp8u* pSrc, int len, IppsSHA1State* pState))
+IPPAPI(IppStatus, ippsSHA1GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA1State* pState))
+IPPAPI(IppStatus, ippsSHA1Final,(Ipp8u* pMD, IppsSHA1State* pState))
IPPAPI(IppStatus, ippsSHA1MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* SHA224 Hash Primitives */
IPPAPI(IppStatus, ippsSHA224GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSHA224Init,(IppsSHA224State* pCtx))
-IPPAPI(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcCtx, IppsSHA224State* pDstCtx))
+IPPAPI(IppStatus, ippsSHA224Init,(IppsSHA224State* pState))
+IPPAPI(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcState, IppsSHA224State* pDstState))
-IPPAPI(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pCtx))
+IPPAPI(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pState))
-IPPAPI(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pCtx))
-IPPAPI(IppStatus, ippsSHA224GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA224State* pCtx))
-IPPAPI(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pCtx))
+IPPAPI(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pState))
+IPPAPI(IppStatus, ippsSHA224GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA224State* pState))
+IPPAPI(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pState))
IPPAPI(IppStatus, ippsSHA224MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* SHA256 Hash Primitives */
IPPAPI(IppStatus, ippsSHA256GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSHA256Init,(IppsSHA256State* pCtx))
-IPPAPI(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcCtx, IppsSHA256State* pDstCtx))
+IPPAPI(IppStatus, ippsSHA256Init,(IppsSHA256State* pState))
+IPPAPI(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcState, IppsSHA256State* pDstState))
-IPPAPI(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pCtx))
+IPPAPI(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pState))
-IPPAPI(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pCtx))
-IPPAPI(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pCtx))
-IPPAPI(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pCtx))
+IPPAPI(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pState))
+IPPAPI(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pState))
+IPPAPI(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pState))
IPPAPI(IppStatus, ippsSHA256MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* SHA384 Hash Primitives */
IPPAPI(IppStatus, ippsSHA384GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSHA384Init,(IppsSHA384State* pCtx))
-IPPAPI(IppStatus, ippsSHA384Duplicate,(const IppsSHA384State* pSrcCtx, IppsSHA384State* pDstCtx))
+IPPAPI(IppStatus, ippsSHA384Init,(IppsSHA384State* pState))
+IPPAPI(IppStatus, ippsSHA384Duplicate,(const IppsSHA384State* pSrcState, IppsSHA384State* pDstState))
-IPPAPI(IppStatus, ippsSHA384Pack,(const IppsSHA384State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSHA384Unpack,(const Ipp8u* pBuffer, IppsSHA384State* pCtx))
+IPPAPI(IppStatus, ippsSHA384Pack,(const IppsSHA384State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSHA384Unpack,(const Ipp8u* pBuffer, IppsSHA384State* pState))
-IPPAPI(IppStatus, ippsSHA384Update,(const Ipp8u* pSrc, int len, IppsSHA384State* pCtx))
-IPPAPI(IppStatus, ippsSHA384GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA384State* pCtx))
-IPPAPI(IppStatus, ippsSHA384Final,(Ipp8u* pMD, IppsSHA384State* pCtx))
+IPPAPI(IppStatus, ippsSHA384Update,(const Ipp8u* pSrc, int len, IppsSHA384State* pState))
+IPPAPI(IppStatus, ippsSHA384GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA384State* pState))
+IPPAPI(IppStatus, ippsSHA384Final,(Ipp8u* pMD, IppsSHA384State* pState))
IPPAPI(IppStatus, ippsSHA384MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* SHA512 Hash Primitives */
IPPAPI(IppStatus, ippsSHA512GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSHA512Init,(IppsSHA512State* pCtx))
-IPPAPI(IppStatus, ippsSHA512Duplicate,(const IppsSHA512State* pSrcCtx, IppsSHA512State* pDstCtx))
+IPPAPI(IppStatus, ippsSHA512Init,(IppsSHA512State* pState))
+IPPAPI(IppStatus, ippsSHA512Duplicate,(const IppsSHA512State* pSrcState, IppsSHA512State* pDstState))
-IPPAPI(IppStatus, ippsSHA512Pack,(const IppsSHA512State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSHA512Unpack,(const Ipp8u* pBuffer, IppsSHA512State* pCtx))
+IPPAPI(IppStatus, ippsSHA512Pack,(const IppsSHA512State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSHA512Unpack,(const Ipp8u* pBuffer, IppsSHA512State* pState))
-IPPAPI(IppStatus, ippsSHA512Update,(const Ipp8u* pSrc, int len, IppsSHA512State* pCtx))
-IPPAPI(IppStatus, ippsSHA512GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA512State* pCtx))
-IPPAPI(IppStatus, ippsSHA512Final,(Ipp8u* pMD, IppsSHA512State* pCtx))
+IPPAPI(IppStatus, ippsSHA512Update,(const Ipp8u* pSrc, int len, IppsSHA512State* pState))
+IPPAPI(IppStatus, ippsSHA512GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA512State* pState))
+IPPAPI(IppStatus, ippsSHA512Final,(Ipp8u* pMD, IppsSHA512State* pState))
IPPAPI(IppStatus, ippsSHA512MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* MD5 Hash Primitives */
IPPAPI(IppStatus, ippsMD5GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsMD5Init,(IppsMD5State* pCtx))
-IPPAPI(IppStatus, ippsMD5Duplicate,(const IppsMD5State* pSrcCtx, IppsMD5State* pDstCtx))
+IPPAPI(IppStatus, ippsMD5Init,(IppsMD5State* pState))
+IPPAPI(IppStatus, ippsMD5Duplicate,(const IppsMD5State* pSrcState, IppsMD5State* pDstState))
-IPPAPI(IppStatus, ippsMD5Pack,(const IppsMD5State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsMD5Unpack,(const Ipp8u* pBuffer, IppsMD5State* pCtx))
+IPPAPI(IppStatus, ippsMD5Pack,(const IppsMD5State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsMD5Unpack,(const Ipp8u* pBuffer, IppsMD5State* pState))
-IPPAPI(IppStatus, ippsMD5Update,(const Ipp8u* pSrc, int len, IppsMD5State* pCtx))
-IPPAPI(IppStatus, ippsMD5GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsMD5State* pCtx))
-IPPAPI(IppStatus, ippsMD5Final,(Ipp8u* pMD, IppsMD5State* pCtx))
+IPPAPI(IppStatus, ippsMD5Update,(const Ipp8u* pSrc, int len, IppsMD5State* pState))
+IPPAPI(IppStatus, ippsMD5GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsMD5State* pState))
+IPPAPI(IppStatus, ippsMD5Final,(Ipp8u* pMD, IppsMD5State* pState))
IPPAPI(IppStatus, ippsMD5MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* SM3 Hash Primitives */
IPPAPI(IppStatus, ippsSM3GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsSM3Init,(IppsSM3State* pCtx))
-IPPAPI(IppStatus, ippsSM3Duplicate,(const IppsSM3State* pSrcCtx, IppsSM3State* pDstCtx))
+IPPAPI(IppStatus, ippsSM3Init,(IppsSM3State* pState))
+IPPAPI(IppStatus, ippsSM3Duplicate,(const IppsSM3State* pSrcState, IppsSM3State* pDstState))
-IPPAPI(IppStatus, ippsSM3Pack,(const IppsSM3State* pCtx, Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsSM3Unpack,(const Ipp8u* pBuffer, IppsSM3State* pCtx))
+IPPAPI(IppStatus, ippsSM3Pack,(const IppsSM3State* pState, Ipp8u* pBuffer))
+IPPAPI(IppStatus, ippsSM3Unpack,(const Ipp8u* pBuffer, IppsSM3State* pState))
-IPPAPI(IppStatus, ippsSM3Update,(const Ipp8u* pSrc, int len, IppsSM3State* pCtx))
-IPPAPI(IppStatus, ippsSM3GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSM3State* pCtx))
-IPPAPI(IppStatus, ippsSM3Final,(Ipp8u* pMD, IppsSM3State* pCtx))
+IPPAPI(IppStatus, ippsSM3Update,(const Ipp8u* pSrc, int len, IppsSM3State* pState))
+IPPAPI(IppStatus, ippsSM3GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSM3State* pState))
+IPPAPI(IppStatus, ippsSM3Final,(Ipp8u* pMD, IppsSM3State* pState))
IPPAPI(IppStatus, ippsSM3MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
/* generalized Hash Primitives */
IPPAPI(IppStatus, ippsHashGetSize,(int* pSize))
-IPPAPI(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId hashAlg))
+IPPAPI(IppStatus, ippsHashInit,(IppsHashState* pState, IppHashAlgId hashAlg))
-IPPAPI(IppStatus, ippsHashPack,(const IppsHashState* pCtx, Ipp8u* pBuffer, int bufSize))
-IPPAPI(IppStatus, ippsHashUnpack,(const Ipp8u* pBuffer, IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashDuplicate,(const IppsHashState* pSrcCtx, IppsHashState* pDstCtx))
+IPPAPI(IppStatus, ippsHashPack,(const IppsHashState* pState, Ipp8u* pBuffer, int bufSize))
+IPPAPI(IppStatus, ippsHashUnpack,(const Ipp8u* pBuffer, IppsHashState* pState))
+IPPAPI(IppStatus, ippsHashDuplicate,(const IppsHashState* pSrcState, IppsHashState* pDstState))
-IPPAPI(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashGetTag,(Ipp8u* pMD, int tagLen, const IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx))
+IPPAPI(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pState))
+IPPAPI(IppStatus, ippsHashGetTag,(Ipp8u* pTag, int tagLen, const IppsHashState* pState))
+IPPAPI(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pState))
IPPAPI(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int len, Ipp8u* pMD, IppHashAlgId hashAlg))
/* method based generalized (reduced memory footprint) Hash Primitives */
@@ -476,15 +508,15 @@ IPPAPI( const IppsHashMethod*, ippsHashMethod_SHA512_256, (void) )
IPPAPI( const IppsHashMethod*, ippsHashMethod_SHA512_224, (void) )
IPPAPI(IppStatus, ippsHashGetSize_rmf,(int* pSize))
-IPPAPI(IppStatus, ippsHashInit_rmf,(IppsHashState_rmf* pCtx, const IppsHashMethod* pMethod))
+IPPAPI(IppStatus, ippsHashInit_rmf,(IppsHashState_rmf* pState, const IppsHashMethod* pMethod))
-IPPAPI(IppStatus, ippsHashPack_rmf,(const IppsHashState_rmf* pCtx, Ipp8u* pBuffer, int bufSize))
-IPPAPI(IppStatus, ippsHashUnpack_rmf,(const Ipp8u* pBuffer, IppsHashState_rmf* pCtx))
-IPPAPI(IppStatus, ippsHashDuplicate_rmf,(const IppsHashState_rmf* pSrcCtx, IppsHashState_rmf* pDstCtx))
+IPPAPI(IppStatus, ippsHashPack_rmf,(const IppsHashState_rmf* pState, Ipp8u* pBuffer, int bufSize))
+IPPAPI(IppStatus, ippsHashUnpack_rmf,(const Ipp8u* pBuffer, IppsHashState_rmf* pState))
+IPPAPI(IppStatus, ippsHashDuplicate_rmf,(const IppsHashState_rmf* pSrcState, IppsHashState_rmf* pDstState))
-IPPAPI(IppStatus, ippsHashUpdate_rmf,(const Ipp8u* pSrc, int len, IppsHashState_rmf* pCtx))
-IPPAPI(IppStatus, ippsHashGetTag_rmf,(Ipp8u* pMD, int tagLen, const IppsHashState_rmf* pCtx))
-IPPAPI(IppStatus, ippsHashFinal_rmf,(Ipp8u* pMD, IppsHashState_rmf* pCtx))
+IPPAPI(IppStatus, ippsHashUpdate_rmf,(const Ipp8u* pSrc, int len, IppsHashState_rmf* pState))
+IPPAPI(IppStatus, ippsHashGetTag_rmf,(Ipp8u* pMD, int tagLen, const IppsHashState_rmf* pState))
+IPPAPI(IppStatus, ippsHashFinal_rmf,(Ipp8u* pMD, IppsHashState_rmf* pState))
IPPAPI(IppStatus, ippsHashMessage_rmf,(const Ipp8u* pMsg, int len, Ipp8u* pMD, const IppsHashMethod* pMethod))
/* general MGF Primitives*/
@@ -888,48 +920,48 @@ IPPAPI(IppStatus, ippsECCPGetSizeStd224r1,(int* pSize))
IPPAPI(IppStatus, ippsECCPGetSizeStd256r1,(int* pSize))
IPPAPI(IppStatus, ippsECCPGetSizeStd384r1,(int* pSize))
IPPAPI(IppStatus, ippsECCPGetSizeStd521r1,(int* pSize))
-IPPAPI(IppStatus, ippsECCPGetSizeStdSM2,(int* pSize))
-
-IPPAPI(IppStatus, ippsECCPInit,(int feBitSize, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd128r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd128r2,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd192r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd224r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd256r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd384r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStd521r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPInitStdSM2,(IppsECCPState* pECC))
+IPPAPI(IppStatus, ippsECCPGetSizeStdSM2, (int* pSize))
+
+IPPAPI(IppStatus, ippsECCPInit,(int feBitSize, IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd128r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd128r2,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd192r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd224r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd256r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd384r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStd521r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPInitStdSM2, (IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPSet,(const IppsBigNumState* pPrime,
const IppsBigNumState* pA, const IppsBigNumState* pB,
const IppsBigNumState* pGX,const IppsBigNumState* pGY,const IppsBigNumState* pOrder,
int cofactor,
- IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd,(IppECCType flag, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd128r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd128r2,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd192r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd224r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd256r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd384r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStd521r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetStdSM2,(IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPBindGxyTblStd192r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPBindGxyTblStd224r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPBindGxyTblStd256r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPBindGxyTblStd384r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPBindGxyTblStd521r1,(IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPBindGxyTblStdSM2, (IppsECCPState* pECC))
+ IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd,(IppECCType flag, IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd128r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd128r2,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd192r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd224r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd256r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd384r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStd521r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPSetStdSM2, (IppsECCPState* pEC))
+
+IPPAPI(IppStatus, ippsECCPBindGxyTblStd192r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPBindGxyTblStd224r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPBindGxyTblStd256r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPBindGxyTblStd384r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPBindGxyTblStd521r1,(IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPBindGxyTblStdSM2, (IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPGet,(IppsBigNumState* pPrime,
IppsBigNumState* pA, IppsBigNumState* pB,
IppsBigNumState* pGX,IppsBigNumState* pGY,IppsBigNumState* pOrder,
int* cofactor,
- IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pECC))
+ IppsECCPState* pEC))
+IPPAPI(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pEC))
-IPPAPI(IppStatus, ippsECCPValidate,(int nTrials, IppECResult* pResult, IppsECCPState* pECC,
+IPPAPI(IppStatus, ippsECCPValidate,(int nTrials, IppECResult* pResult, IppsECCPState* pEC,
IppBitSupplier rndFunc, void* pRndParam))
/* EC Point */
@@ -939,119 +971,119 @@ IPPAPI(IppStatus, ippsECCPPointInit,(int feBitSize, IppsECCPPointState* pPoint))
/* Setup/retrieve point's coordinates */
IPPAPI(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX, const IppsBigNumState* pY,
- IppsECCPPointState* pPoint, IppsECCPState* pECC))
+ IppsECCPPointState* pPoint, IppsECCPState* pEC))
-IPPAPI(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pECC))
+IPPAPI(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, IppsBigNumState* pY,
- const IppsECCPPointState* pPoint, IppsECCPState* pECC))
+ const IppsECCPPointState* pPoint, IppsECCPState* pEC))
/* EC Point Operations */
IPPAPI(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP,
- IppECResult* pResult, IppsECCPState* pECC))
+ IppECResult* pResult, IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ,
- IppECResult* pResult, IppsECCPState* pECC))
+ IppECResult* pResult, IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPNegativePoint,(const IppsECCPPointState* pP,
- IppsECCPPointState* pR, IppsECCPState* pECC))
+ IppsECCPPointState* pR, IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ,
- IppsECCPPointState* pR, IppsECCPState* pECC))
+ IppsECCPPointState* pR, IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP, const IppsBigNumState* pK,
- IppsECCPPointState* pR, IppsECCPState* pECC))
+ IppsECCPPointState* pR, IppsECCPState* pEC))
/* Key Generation, Setup and Validation */
IPPAPI(IppStatus, ippsECCPGenKeyPair,(IppsBigNumState* pPrivate, IppsECCPPointState* pPublic,
- IppsECCPState* pECC,
+ IppsECCPState* pEC,
IppBitSupplier rndFunc, void* pRndParam))
IPPAPI(IppStatus, ippsECCPPublicKey,(const IppsBigNumState* pPrivate,
IppsECCPPointState* pPublic,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPValidateKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic,
IppECResult* pResult,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPSetKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic,
IppBool regular,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
/* Shared Secret (DH scheme ) */
IPPAPI(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA,
const IppsECCPPointState* pPublicB,
IppsBigNumState* pShare,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPSharedSecretDHC,(const IppsBigNumState* pPrivateA,
const IppsECCPPointState* pPublicB,
IppsBigNumState* pShare,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
/* Sing/Verify */
IPPAPI(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest,
const IppsBigNumState* pPrivate,
IppsBigNumState* pSignX, IppsBigNumState* pSignY,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest,
const IppsBigNumState* pSignX, const IppsBigNumState* pSignY,
IppECResult* pResult,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPSignNR,(const IppsBigNumState* pMsgDigest,
const IppsBigNumState* pPrivate,
IppsBigNumState* pSignX, IppsBigNumState* pSignY,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPVerifyNR,(const IppsBigNumState* pMsgDigest,
const IppsBigNumState* pSignX, const IppsBigNumState* pSignY,
IppECResult* pResult,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPSignSM2,(const IppsBigNumState* pMsgDigest,
const IppsBigNumState* pRegPrivate,
const IppsBigNumState* pEphPrivate,
IppsBigNumState* pSignR, IppsBigNumState* pSignS,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
IPPAPI(IppStatus, ippsECCPVerifySM2,(const IppsBigNumState* pMsgDigest,
const IppsECCPPointState* pRegPublic,
const IppsBigNumState* pSignR, const IppsBigNumState* pSignS,
IppECResult* pResult,
- IppsECCPState* pECC))
+ IppsECCPState* pEC))
/*
// GF over prime and its extension
*/
-IPPAPI(IppStatus, ippsGFpGetSize, (int bitSize, int* pStateSizeInBytes))
-IPPAPI(IppStatus, ippsGFpInitArbitrary,(const IppsBigNumState* pPrime, int primeBitSize, IppsGFpState* pGF))
-IPPAPI(IppStatus, ippsGFpInitFixed,(int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF))
-IPPAPI(IppStatus, ippsGFpInit, (const IppsBigNumState* pPrime, int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF))
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p192r1,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p224r1,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256r1,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p384r1,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p521r1,(void) )
+IPPAPI(IppStatus, ippsGFpGetSize, (int feBitSize, int* pSize))
+IPPAPI(IppStatus, ippsGFpInitArbitrary,(const IppsBigNumState* pPrime, int primeBitSize, IppsGFpState* pGFp))
+IPPAPI(IppStatus, ippsGFpInitFixed,(int primeBitSize, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFp))
+IPPAPI(IppStatus, ippsGFpInit, (const IppsBigNumState* pPrime, int primeBitSize, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFp))
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p192r1, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p224r1, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256r1, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p384r1, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p521r1, (void) )
IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256sm2,(void) )
IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256bn, (void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256, (void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpMethod_pArb, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_p256, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpMethod_pArb, (void) )
-IPPAPI(IppStatus, ippsGFpxGetSize,(const IppsGFpState* pGroundGF, int degree, int* pStateSizeInBytes))
-IPPAPI(IppStatus, ippsGFpxInit, (const IppsGFpState* pGroundGF, int extDeg, const IppsGFpElement* const ppGroundElm[], int ne, const IppsGFpMethod* method, IppsGFpState* pGFpx))
-IPPAPI(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, int extDeg, const IppsGFpElement* pGroundElm, const IppsGFpMethod* method, IppsGFpState* pGFpx))
+IPPAPI(IppStatus, ippsGFpxGetSize,(const IppsGFpState* pGroundGF, int degree, int* pSize))
+IPPAPI(IppStatus, ippsGFpxInit, (const IppsGFpState* pGroundGF, int extDeg, const IppsGFpElement* const ppGroundElm[], int nElm, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFpx))
+IPPAPI(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, int extDeg, const IppsGFpElement* pGroundElm, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFpx))
IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom2_epid2,(void) )
IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom3_epid2,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom2,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom3,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom,(void) )
-IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_com, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom2, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom3, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_binom, (void) )
+IPPAPI( const IppsGFpMethod*, ippsGFpxMethod_com, (void) )
-IPPAPI(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGF, int* pBufferSize))
+IPPAPI(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGFp, int* pBufferSize))
IPPAPI(IppStatus, ippsGFpElementGetSize,(const IppsGFpState* pGFp, int* pElementSize))
IPPAPI(IppStatus, ippsGFpElementInit, (const Ipp32u* pA, int lenA, IppsGFpElement* pR, IppsGFpState* pGFp))
-IPPAPI(IppStatus, ippsGFpSetElement, (const Ipp32u* pA, int nsA, IppsGFpElement* pR, IppsGFpState* pGFp))
-IPPAPI(IppStatus, ippsGFpSetElementRegular,(const IppsBigNumState* pBN, IppsGFpElement* pElm, IppsGFpState* pGF))
+IPPAPI(IppStatus, ippsGFpSetElement, (const Ipp32u* pA, int lenA, IppsGFpElement* pR, IppsGFpState* pGFp))
+IPPAPI(IppStatus, ippsGFpSetElementRegular,(const IppsBigNumState* pBN, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpSetElementOctString,(const Ipp8u* pStr, int strSize, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpSetElementRandom,(IppsGFpElement* pR, IppsGFpState* pGFp, IppBitSupplier rndFunc, void* pRndParam))
-IPPAPI(IppStatus, ippsGFpSetElementHash,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGF, IppHashAlgId hashID))
-IPPAPI(IppStatus, ippsGFpSetElementHash_rmf,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGF, const IppsHashMethod* pMethod))
+IPPAPI(IppStatus, ippsGFpSetElementHash,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGFp, IppHashAlgId hashID))
+IPPAPI(IppStatus, ippsGFpSetElementHash_rmf,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGFp, const IppsHashMethod* pMethod))
IPPAPI(IppStatus, ippsGFpCpyElement,(const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp))
-IPPAPI(IppStatus, ippsGFpGetElement,(const IppsGFpElement* pA, Ipp32u* pDataA, int nsA, IppsGFpState* pGFp))
+IPPAPI(IppStatus, ippsGFpGetElement,(const IppsGFpElement* pA, Ipp32u* pDataA, int lenA, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpGetElementOctString,(const IppsGFpElement* pA, Ipp8u* pStr, int strSize, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpCmpElement,(const IppsGFpElement* pA, const IppsGFpElement* pB, int* pResult, const IppsGFpState* pGFp))
@@ -1067,15 +1099,15 @@ IPPAPI(IppStatus, ippsGFpAdd, (const IppsGFpElement* pA, const IppsGFpElement* p
IPPAPI(IppStatus, ippsGFpSub, (const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpMul, (const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpExp, (const IppsGFpElement* pA, const IppsBigNumState* pE, IppsGFpElement* pR, IppsGFpState* pGFp, Ipp8u* pScratchBuffer))
-IPPAPI(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems, IppsGFpElement* pElmR, IppsGFpState* pGF, Ipp8u* pScratchBuffer))
+IPPAPI(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems, IppsGFpElement* pR, IppsGFpState* pGFp, Ipp8u* pScratchBuffer))
IPPAPI(IppStatus, ippsGFpAdd_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpSub_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB, IppsGFpElement* pR, IppsGFpState* pGFp))
IPPAPI(IppStatus, ippsGFpMul_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB, IppsGFpElement* pR, IppsGFpState* pGFp))
/* ================== */
-IPPAPI(IppStatus, ippsGFpECGetSize,(const IppsGFpState* pGF, int* pCtxSizeInBytes))
-IPPAPI(IppStatus, ippsGFpECInit, (const IppsGFpState* pGF,
+IPPAPI(IppStatus, ippsGFpECGetSize,(const IppsGFpState* pGFp, int* pSize))
+IPPAPI(IppStatus, ippsGFpECInit, (const IppsGFpState* pGFp,
const IppsGFpElement* pA, const IppsGFpElement* pB,
IppsGFpECState* pEC))
@@ -1086,15 +1118,15 @@ IPPAPI(IppStatus, ippsGFpECSetSubgroup,(const IppsGFpElement* pX, const IppsGFpE
const IppsBigNumState* pCofactor,
IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd128r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd128r2,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd192r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd224r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd256r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd384r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStd521r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStdSM2, (const IppsGFpState* pGF, IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECInitStdBN256,(const IppsGFpState* pGF, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd128r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd128r2,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd192r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd224r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd256r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd384r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStd521r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStdSM2, (const IppsGFpState* pGFp, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECInitStdBN256,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECBindGxyTblStd192r1,(IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECBindGxyTblStd224r1,(IppsGFpECState* pEC))
@@ -1103,10 +1135,10 @@ IPPAPI(IppStatus, ippsGFpECBindGxyTblStd384r1,(IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECBindGxyTblStd521r1,(IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECBindGxyTblStdSM2, (IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECGet,(IppsGFpState** const ppGF,
+IPPAPI(IppStatus, ippsGFpECGet,(IppsGFpState** const ppGFp,
IppsGFpElement* pA, IppsGFpElement* pB,
const IppsGFpECState* pEC))
-IPPAPI(IppStatus, ippsGFpECGetSubgroup,(IppsGFpState** const ppGF,
+IPPAPI(IppStatus, ippsGFpECGetSubgroup,(IppsGFpState** const ppGFp,
IppsGFpElement* pX, IppsGFpElement* pY,
IppsBigNumState* pOrder,IppsBigNumState* pCofactor,
const IppsGFpECState* pEC))
@@ -1115,7 +1147,7 @@ IPPAPI(IppStatus, ippsGFpECScratchBufferSize,(int nScalars, const IppsGFpECState
IPPAPI(IppStatus, ippsGFpECVerify,(IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-IPPAPI(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSizeInBytes))
+IPPAPI(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSize))
IPPAPI(IppStatus, ippsGFpECPointInit, (const IppsGFpElement* pX, const IppsGFpElement* pY, IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECSetPointAtInfinity,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
@@ -1127,6 +1159,8 @@ IPPAPI(IppStatus, ippsGFpECSetPointHash,(Ipp32u hdr, const Ipp8u* pMsg, int msgL
IPPAPI(IppStatus, ippsGFpECSetPointHash_rmf,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppsGFpECPoint* pPoint, IppsGFpECState* pEC, const IppsHashMethod* pMethod, Ipp8u* pScratchBuffer))
IPPAPI(IppStatus, ippsGFpECGetPoint,(const IppsGFpECPoint* pPoint, IppsGFpElement* pX, IppsGFpElement* pY, IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECGetPointRegular,(const IppsGFpECPoint* pPoint, IppsBigNumState* pX, IppsBigNumState* pY, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECSetPointOctString,(const Ipp8u* pStr, int strLen, IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
+IPPAPI(IppStatus, ippsGFpECGetPointOctString,(const IppsGFpECPoint* pPoint, Ipp8u* pStr, int strLen, IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP, IppECResult* pResult, IppsGFpECState* pEC))
IPPAPI(IppStatus, ippsGFpECTstPointInSubgroup,(const IppsGFpECPoint* pP, IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
@@ -1187,6 +1221,23 @@ IPPAPI(IppStatus, ippsGFpECVerifySM2,(const IppsBigNumState* pMsgDigest,
IppECResult* pResult,
IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+IPPAPI(IppStatus, ippsGFpECESGetSize_SM2, (const IppsGFpECState* pEC, int* pSize))
+IPPAPI(IppStatus, ippsGFpECESInit_SM2, (IppsGFpECState* pEC,
+ IppsECESState_SM2* pState, int avaliableCtxSize))
+IPPAPI(IppStatus, ippsGFpECESSetKey_SM2, (const IppsBigNumState* pPrivate,
+ const IppsGFpECPoint* pPublic,
+ IppsECESState_SM2* pState,
+ IppsGFpECState* pEC,
+ Ipp8u* pEcScratchBuffer))
+IPPAPI(IppStatus, ippsGFpECESStart_SM2, (IppsECESState_SM2* pState))
+IPPAPI(IppStatus, ippsGFpECESEncrypt_SM2, (const Ipp8u* pInput, Ipp8u* pOutput,
+ int dataLen, IppsECESState_SM2* pState))
+IPPAPI(IppStatus, ippsGFpECESDecrypt_SM2, (const Ipp8u* pInput, Ipp8u* pOutput,
+ int dataLen, IppsECESState_SM2* pState))
+IPPAPI(IppStatus, ippsGFpECESFinal_SM2, (Ipp8u* pTag, int tagLen, IppsECESState_SM2* pState))
+IPPAPI(IppStatus, ippsGFpECESGetBuffersSize_SM2, (int* pPublicKeySize,
+ int* pMaximumTagSize, const IppsECESState_SM2* pState))
+
#ifdef __cplusplus
}
#endif
diff --git a/ext/ipp/include/ippcpdefs.h b/ext/ipp/include/ippcpdefs.h
index 083c360..974b54a 100644
--- a/ext/ipp/include/ippcpdefs.h
+++ b/ext/ipp/include/ippcpdefs.h
@@ -1,31 +1,49 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
-// Cryptographic Primitives (ippCP) definitions.
-//
-//
-*/
+/*******************************************************************************
+* Copyright 2012-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
-/*
+/*
// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
+// Cryptographic Primitives (ippCP) definitions
// Basic Types and Macro Definitions
-//
-//
+//
+//
*/
@@ -124,6 +142,8 @@ extern "C" {
#define IPP_UINT64 unsigned long long
#endif
+#define IPP_COUNT_OF( obj ) (sizeof(obj)/sizeof(obj[0]))
+
#define IPP_PI ( 3.14159265358979323846 ) /* ANSI C does not support M_PI */
#define IPP_2PI ( 6.28318530717958647692 ) /* 2*pi */
#define IPP_PI2 ( 1.57079632679489661923 ) /* pi/2 */
@@ -272,26 +292,26 @@ typedef enum {
#ifndef IPP_CPU_FEATURES__
#define IPP_CPU_FEATURES__
-#define ippCPUID_MMX 0x00000001 /* Intel(R) Architecture MMX technology supported */
-#define ippCPUID_SSE 0x00000002 /* Intel(R) Streaming SIMD Extensions */
-#define ippCPUID_SSE2 0x00000004 /* Intel(R) Streaming SIMD Extensions 2 */
-#define ippCPUID_SSE3 0x00000008 /* Intel(R) Streaming SIMD Extensions 3 */
-#define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 */
-#define ippCPUID_MOVBE 0x00000020 /* Intel(R) MOVBE instruction */
-#define ippCPUID_SSE41 0x00000040 /* Intel(R) Streaming SIMD Extensions 4.1 */
-#define ippCPUID_SSE42 0x00000080 /* Intel(R) Streaming SIMD Extensions 4.2 */
+#define ippCPUID_MMX 0x00000001 /* Intel(R) architecture with MMX(TM) technology supported */
+#define ippCPUID_SSE 0x00000002 /* Intel(R) Streaming SIMD Extensions instruction set */
+#define ippCPUID_SSE2 0x00000004 /* Intel(R) Streaming SIMD Extensions 2 instruction set */
+#define ippCPUID_SSE3 0x00000008 /* Intel(R) Streaming SIMD Extensions 3 instruction set */
+#define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 instruction set */
+#define ippCPUID_MOVBE 0x00000020 /* Intel(R) instruction MOVBE */
+#define ippCPUID_SSE41 0x00000040 /* Intel(R) Streaming SIMD Extensions 4.1 instruction set */
+#define ippCPUID_SSE42 0x00000080 /* Intel(R) Streaming SIMD Extensions 4.2 instruction set */
#define ippCPUID_AVX 0x00000100 /* Intel(R) Advanced Vector Extensions instruction set */
#define ippAVX_ENABLEDBYOS 0x00000200 /* Intel(R) Advanced Vector Extensions instruction set is supported by OS */
#define ippCPUID_AES 0x00000400 /* Intel(R) AES New Instructions */
-#define ippCPUID_CLMUL 0x00000800 /* Intel(R) CLMUL instruction */
+#define ippCPUID_CLMUL 0x00000800 /* Intel(R) instruction PCLMULQDQ */
#define ippCPUID_ABR 0x00001000 /* Reserved */
-#define ippCPUID_RDRAND 0x00002000 /* Intel(R) RDRAND instruction */
-#define ippCPUID_F16C 0x00004000 /* Intel(R) F16C new instructions */
-#define ippCPUID_AVX2 0x00008000 /* Intel(R) Advanced Vector Extensions 2 instruction set */
-#define ippCPUID_ADCOX 0x00010000 /* Intel(R) ADOX/ADCX new instructions */
-#define ippCPUID_RDSEED 0x00020000 /* Intel(R) RDSEED instruction */
-#define ippCPUID_PREFETCHW 0x00040000 /* Intel(R) PREFETCHW instruction */
-#define ippCPUID_SHA 0x00080000 /* Intel(R) SHA new instructions */
+#define ippCPUID_RDRAND 0x00002000 /* Intel(R) instruction RDRAND */
+#define ippCPUID_F16C 0x00004000 /* Intel(R) instruction F16C */
+#define ippCPUID_AVX2 0x00008000 /* Intel(R) Advanced Vector Extensions 2 */
+#define ippCPUID_ADCOX 0x00010000 /* Intel(R) instructions ADOX/ADCX */
+#define ippCPUID_RDSEED 0x00020000 /* Intel(R) instruction RDSEED */
+#define ippCPUID_PREFETCHW 0x00040000 /* Intel(R) instruction PREFETCHW */
+#define ippCPUID_SHA 0x00080000 /* Intel(R) Secure Hash Algorithm Extensions */
#define ippCPUID_AVX512F 0x00100000 /* Intel(R) Advanced Vector Extensions 512 Foundation instruction set */
#define ippCPUID_AVX512CD 0x00200000 /* Intel(R) Advanced Vector Extensions 512 CD instruction set */
#define ippCPUID_AVX512ER 0x00400000 /* Intel(R) Advanced Vector Extensions 512 ER instruction set */
@@ -327,6 +347,8 @@ extern "C" {
typedef signed int IppStatus;
/* start of common with ippCrypto part - any changes MUST be done in both repositories - IPP & ippCrypto */
+#define ippStsCpuNotSupportedErr -9999 /* The target CPU is not supported. */
+#define ippStsUnknownStatusCodeErr -216 /* Unknown status code. */
#define ippStsLoadDynErr -221 /* Error when loading the dynamic library. */
#define ippStsLengthErr -15 /* Incorrect value for string length. */
#define ippStsNotSupportedModeErr -14 /* The requested mode is currently not supported. */
@@ -347,6 +369,7 @@ typedef signed int IppStatus;
#define ippStsNoOperation 1 /* No operation has been executed. */
#define ippStsDivByZero 2 /* Zero value(s) for the divisor in the Div function. */
#define ippStsWaterfall 43 /* Cannot load required library, waterfall is used. */
+#define ippStsFeaturesCombination 51 /* Wrong combination of features. */
/* end of common with ippCrypto part */
#ifdef __cplusplus
@@ -373,9 +396,10 @@ typedef signed int IppStatus;
#define ippStsPaddingSchemeErr -1002 /* Invalid padding scheme. */
#define ippStsBadModulusErr -1001 /* Bad modulus caused a failure in module inversion. */
#define ippStsInsufficientEntropy 25 /* Generation of the prime/key failed due to insufficient entropy in the random seed and stimulus bit string. */
+#define ippStsNotSupportedCpu 36 /* The CPU is not supported. */
/* end of ippCrypto specific statuses - any changes MUST be done in both repositories - IPP & ippCrypto */
-#ifndef IPPCPDEFS_H__
+#if (!defined IPPCPDEFS_H__) || defined( _OWN_BLDPCS )
#define IPPCPDEFS_H__
#ifdef __cplusplus
@@ -528,6 +552,7 @@ typedef struct _cpAES_CMAC IppsAES_CMACState;
*/
#define BN_MAXBITSIZE (16*1024) /* bn max size (bits) */
+
typedef enum {
ippBigNumNEG = 0, IppsBigNumNEG = 0,
ippBigNumPOS = 1, IppsBigNumPOS = 1
@@ -575,7 +600,7 @@ typedef IppStatus (IPP_STDCALL *IppBitSupplier)(Ipp32u* pRand, int nBits, void*
// =========================================================
*/
#define MIN_RSA_SIZE (8)
-#define MAX_RSA_SIZE (8*1024)
+#define MAX_RSA_SIZE (16*1024)
typedef struct _cpRSA IppsRSAState;
@@ -758,20 +783,24 @@ typedef struct {
int elementLen;
} IppsGFpInfo;
-#endif /* _OWN_BLDPCS */
+typedef struct _cpStateECES_SM2 IppsECESState_SM2;
+
+#endif /* !defined( _OWN_BLDPCS ) */
+
#ifndef _PCS
-IPPAPI( IppStatus, ippcpSetNumThreads, ( int numThr ))
-IPPAPI( IppStatus, ippcpGetNumThreads, (int* pNumThr) )
IPPAPI( IppStatus, ippcpGetCpuFeatures, ( Ipp64u* pFeaturesMask ))
IPPAPI( IppStatus, ippcpSetCpuFeatures, ( Ipp64u features ))
IPPAPI( Ipp64u, ippcpGetEnabledCpuFeatures, ( void ) )
+IPPAPI( IppStatus, ippcpSetNumThreads, ( int numThr ))
IPPAPI( IppStatus, ippcpInit,( void ))
+IPPAPI( IppStatus, ippcpGetNumThreads, (int* pNumThr) )
IPPAPI( const char*, ippcpGetStatusString, ( IppStatus StsCode ))
IPPAPI( int, ippcpGetEnabledNumThreads, ( void ) )
+IPPAPI( Ipp64u, ippcpGetCpuClocks, (void) )
#endif
#ifdef __cplusplus
}
#endif
-#endif /* IPPCPDEFS_H__ */
+#endif /* !defined IPPCPDEFS_H__ || defined( _OWN_BLDPCS ) */
diff --git a/ext/ipp/include/ippdefs.h b/ext/ipp/include/ippdefs.h
deleted file mode 100644
index ebca21e..0000000
--- a/ext/ipp/include/ippdefs.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
-// Common Types and Macro Definitions
-//
-//
-*/
-
-
-#ifndef IPPDEFS_H__
-#define IPPDEFS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if defined( _IPP_PARALLEL_STATIC ) || defined( _IPP_PARALLEL_DYNAMIC )
- #pragma message("Threaded versions of Intel(R) IPP libraries are deprecated and will be removed in one of the future Intel(R) IPP releases. Use the following link for details: https://software.intel.com/sites/products/ipp-deprecated-features-feedback/")
-#endif
-
-#if defined (_WIN64)
-#define INTEL_PLATFORM "intel64/"
-#elif defined (_WIN32)
-#define INTEL_PLATFORM "ia32/"
-#endif
-
-#if !defined( IPPAPI )
-
- #if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 ))
- #if defined( _MSC_VER ) || defined( __ICL )
- #define IPPAPI( type,name,arg ) \
- __declspec(dllimport) type IPP_STDCALL name arg;
- #else
- #define IPPAPI( type,name,arg ) type IPP_STDCALL name arg;
- #endif
- #else
- #define IPPAPI( type,name,arg ) type IPP_STDCALL name arg;
- #endif
-
-#endif
-
-#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER)) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
- #if( __INTEL_COMPILER >= 1100 ) /* icl 11.0 supports additional comment */
- #if( _MSC_VER >= 1400 )
- #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
- #else
- #pragma message ("your icl version supports additional comment for deprecated functions but it can't be displayed")
- #pragma message ("because internal _MSC_VER macro variable setting requires compatibility with MSVC7.1")
- #pragma message ("use -Qvc8 switch for icl command line to see these additional comments")
- #define IPP_DEPRECATED( comment ) __declspec( deprecated )
- #endif
- #elif( _MSC_FULL_VER >= 140050727 )&&( !defined( __INTEL_COMPILER )) /* VS2005 supports additional comment */
- #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
- #elif( _MSC_VER <= 1200 )&&( !defined( __INTEL_COMPILER )) /* VS 6 doesn't support deprecation */
- #define IPP_DEPRECATED( comment )
- #else
- #define IPP_DEPRECATED( comment ) __declspec( deprecated )
- #endif
-#elif (defined(__ICC) || defined(__ECC) || defined( __GNUC__ )) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
- #if defined( __GNUC__ )
- #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
- #define IPP_DEPRECATED( message ) __attribute__(( deprecated( message )))
- #else
- #define IPP_DEPRECATED( message ) __attribute__(( deprecated ))
- #endif
- #else
- #define IPP_DEPRECATED( comment ) __attribute__(( deprecated ))
- #endif
-#else
- #define IPP_DEPRECATED( comment )
-#endif
-
-#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER))
- #if !defined( IPP_NO_DEFAULT_LIB )
- #if (( defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && defined( _IPP_SEQUENTIAL_STATIC )))
- #elif (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC ))
- #define IPP_NO_DEFAULT_LIB
- #else
- #error Illegal combination of _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC, only one definition can be defined
- #endif
- #endif
-#else
- #define IPP_NO_DEFAULT_LIB
- #if (defined( _IPP_PARALLEL_DYNAMIC ) || defined( _IPP_PARALLEL_STATIC ) || defined(_IPP_SEQUENTIAL_DYNAMIC) || defined(_IPP_SEQUENTIAL_STATIC))
- #pragma message ("defines _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC do not have any effect in current configuration")
- #endif
-#endif
-
-#if !defined( IPP_NO_DEFAULT_LIB )
- #if defined( _IPP_PARALLEL_STATIC )
- #pragma comment( lib, "libiomp5md" )
- #endif
-#endif
-
-#include "ippbase.h"
-#include "ipptypes.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IPPDEFS_H__ */
diff --git a/ext/ipp/include/ipptypes.h b/ext/ipp/include/ipptypes.h
deleted file mode 100644
index 3197f23..0000000
--- a/ext/ipp/include/ipptypes.h
+++ /dev/null
@@ -1,977 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
-// Derivative Types and Macro Definitions
-//
-// The main purpose of this header file is
-// to support compatibility with the legacy
-// domains until their end of life.
-//
-*/
-
-
-#ifndef IPPTYPES_H__
-#define IPPTYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*****************************************************************************/
-/* Below are ippCore domain specific definitions */
-/*****************************************************************************/
-#if !defined( _OWN_BLDPCS )
-
-#ifndef IPP_CPU_FEATURES__
-#define IPP_CPU_FEATURES__
-
-#define ippCPUID_MMX 0x00000001 /* Intel(R) Architecture MMX technology supported */
-#define ippCPUID_SSE 0x00000002 /* Intel(R) Streaming SIMD Extensions */
-#define ippCPUID_SSE2 0x00000004 /* Intel(R) Streaming SIMD Extensions 2 */
-#define ippCPUID_SSE3 0x00000008 /* Intel(R) Streaming SIMD Extensions 3 */
-#define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 */
-#define ippCPUID_MOVBE 0x00000020 /* Intel(R) MOVBE instruction */
-#define ippCPUID_SSE41 0x00000040 /* Intel(R) Streaming SIMD Extensions 4.1 */
-#define ippCPUID_SSE42 0x00000080 /* Intel(R) Streaming SIMD Extensions 4.2 */
-#define ippCPUID_AVX 0x00000100 /* Intel(R) Advanced Vector Extensions instruction set */
-#define ippAVX_ENABLEDBYOS 0x00000200 /* Intel(R) Advanced Vector Extensions instruction set is supported by OS */
-#define ippCPUID_AES 0x00000400 /* Intel(R) AES New Instructions */
-#define ippCPUID_CLMUL 0x00000800 /* Intel(R) CLMUL instruction */
-#define ippCPUID_ABR 0x00001000 /* Reserved */
-#define ippCPUID_RDRAND 0x00002000 /* Intel(R) RDRAND instruction */
-#define ippCPUID_F16C 0x00004000 /* Intel(R) F16C new instructions */
-#define ippCPUID_AVX2 0x00008000 /* Intel(R) Advanced Vector Extensions 2 instruction set */
-#define ippCPUID_ADCOX 0x00010000 /* Intel(R) ADOX/ADCX new instructions */
-#define ippCPUID_RDSEED 0x00020000 /* Intel(R) RDSEED instruction */
-#define ippCPUID_PREFETCHW 0x00040000 /* Intel(R) PREFETCHW instruction */
-#define ippCPUID_SHA 0x00080000 /* Intel(R) SHA new instructions */
-#define ippCPUID_AVX512F 0x00100000 /* Intel(R) Advanced Vector Extensions 512 Foundation instruction set */
-#define ippCPUID_AVX512CD 0x00200000 /* Intel(R) Advanced Vector Extensions 512 CD instruction set */
-#define ippCPUID_AVX512ER 0x00400000 /* Intel(R) Advanced Vector Extensions 512 ER instruction set */
-#define ippCPUID_AVX512PF 0x00800000 /* Intel(R) Advanced Vector Extensions 512 PF instruction set */
-#define ippCPUID_AVX512BW 0x01000000 /* Intel(R) Advanced Vector Extensions 512 BW instruction set */
-#define ippCPUID_AVX512DQ 0x02000000 /* Intel(R) Advanced Vector Extensions 512 DQ instruction set */
-#define ippCPUID_AVX512VL 0x04000000 /* Intel(R) Advanced Vector Extensions 512 VL instruction set */
-#define ippCPUID_AVX512VBMI 0x08000000 /* Intel(R) Advanced Vector Extensions 512 Bit Manipulation instructions */
-#define ippCPUID_MPX 0x10000000 /* Intel(R) Memory Protection Extensions */
-#define ippCPUID_AVX512_4FMADDPS 0x20000000 /* Intel(R) Advanced Vector Extensions 512 DL floating-point single precision */
-#define ippCPUID_AVX512_4VNNIW 0x40000000 /* Intel(R) Advanced Vector Extensions 512 DL enhanced word variable precision */
-#define ippCPUID_KNC 0x80000000 /* Intel(R) Xeon Phi(TM) Coprocessor */
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define INT64_SUFFIX(name) name##L
-#else
- #define INT64_SUFFIX(name) name##LL
-#endif
- #define ippCPUID_AVX512IFMA INT64_SUFFIX(0x100000000) /* Intel(R) Advanced Vector Extensions 512 IFMA (PMADD52) instruction set */
- #define ippCPUID_NOCHECK INT64_SUFFIX(0x8000000000000000) /* Force ippSetCpuFeatures to set CPU features without check */
- #define ippCPUID_GETINFO_A INT64_SUFFIX(0x616f666e69746567) /* Force ippGetCpuFeatures to work as cpuid instruction */
- #define ippAVX512_ENABLEDBYOS INT64_SUFFIX(0x200000000) /* Intel(R) Advanced Vector Extensions 512 is supported by OS */
-
-
-#endif /* IPP_CPU_FEATURES__ */
-
-#define IPP_COUNT_OF( obj ) (sizeof(obj)/sizeof(obj[0]))
-
-typedef struct {
- int type;
- int level;
- int size;
-} IppCache;
-
-/*****************************************************************************/
-/* Below are ippSP domain specific definitions */
-/*****************************************************************************/
-typedef enum {
- ippRndZero,
- ippRndNear,
- ippRndFinancial,
- ippRndHintAccurate=0x10
-} IppRoundMode;
-
-
-typedef enum {
- ippAlgHintNone,
- ippAlgHintFast,
- ippAlgHintAccurate
-} IppHintAlgorithm;
-
-typedef enum {
- ippCmpLess,
- ippCmpLessEq,
- ippCmpEq,
- ippCmpGreaterEq,
- ippCmpGreater
-} IppCmpOp;
-
-typedef enum {
- ippAlgAuto = 0x00000000,
- ippAlgDirect = 0x00000001,
- ippAlgFFT = 0x00000002,
- ippAlgMask = 0x000000FF
-} IppAlgType;
-
-typedef enum {
- ippsNormNone = 0x00000000, /* default */
- ippsNormA = 0x00000100, /* biased normalization */
- ippsNormB = 0x00000200, /* unbiased normalization */
- ippsNormMask = 0x0000FF00
-} IppsNormOp;
-
-typedef enum {
- ippNormInf = 0x00000001,
- ippNormL1 = 0x00000002,
- ippNormL2 = 0x00000004
-} IppNormType;
-
-enum {
- IPP_FFT_DIV_FWD_BY_N = 1,
- IPP_FFT_DIV_INV_BY_N = 2,
- IPP_FFT_DIV_BY_SQRTN = 4,
- IPP_FFT_NODIV_BY_ANY = 8
-};
-
-enum {
- IPP_DIV_FWD_BY_N = 1,
- IPP_DIV_INV_BY_N = 2,
- IPP_DIV_BY_SQRTN = 4,
- IPP_NODIV_BY_ANY = 8
-};
-
-typedef struct {
- Ipp32f rho;
- Ipp32f theta;
-} IppPointPolar;
-
-typedef enum {ippWinBartlett,ippWinBlackman,ippWinHamming,ippWinHann,ippWinRect} IppWinType;
-
-typedef enum { ippButterworth, ippChebyshev1 } IppsIIRFilterType;
-
-typedef enum { ippZCR=0, ippZCXor, ippZCC } IppsZCType;
-
-#if !defined( _OWN_BLDPCS )
-
-typedef struct {
- int left;
- int right;
-} IppsROI;
-
-typedef struct RandUniState_8u IppsRandUniState_8u;
-typedef struct RandUniState_16s IppsRandUniState_16s;
-typedef struct RandUniState_32f IppsRandUniState_32f;
-typedef struct RandUniState_64f IppsRandUniState_64f;
-
-typedef struct RandGaussState_8u IppsRandGaussState_8u;
-typedef struct RandGaussState_16s IppsRandGaussState_16s;
-typedef struct RandGaussState_32f IppsRandGaussState_32f;
-typedef struct RandGaussState_64f IppsRandGaussState_64f;
-
-typedef struct FFTSpec_C_32fc IppsFFTSpec_C_32fc;
-typedef struct FFTSpec_C_32f IppsFFTSpec_C_32f;
-typedef struct FFTSpec_R_32f IppsFFTSpec_R_32f;
-
-typedef struct FFTSpec_C_64fc IppsFFTSpec_C_64fc;
-typedef struct FFTSpec_C_64f IppsFFTSpec_C_64f;
-typedef struct FFTSpec_R_64f IppsFFTSpec_R_64f;
-
-typedef struct DFTSpec_C_32fc IppsDFTSpec_C_32fc;
-typedef struct DFTSpec_C_32f IppsDFTSpec_C_32f;
-typedef struct DFTSpec_R_32f IppsDFTSpec_R_32f;
-
-typedef struct DFTSpec_C_64fc IppsDFTSpec_C_64fc;
-typedef struct DFTSpec_C_64f IppsDFTSpec_C_64f;
-typedef struct DFTSpec_R_64f IppsDFTSpec_R_64f;
-
-typedef struct DCTFwdSpec_32f IppsDCTFwdSpec_32f;
-typedef struct DCTInvSpec_32f IppsDCTInvSpec_32f;
-
-typedef struct DCTFwdSpec_64f IppsDCTFwdSpec_64f;
-typedef struct DCTInvSpec_64f IppsDCTInvSpec_64f;
-
-typedef struct sWTFwdState_32f IppsWTFwdState_32f;
-typedef struct sWTFwdState_8u32f IppsWTFwdState_8u32f;
-typedef struct sWTFwdState_16s32f IppsWTFwdState_16s32f;
-typedef struct sWTFwdState_16u32f IppsWTFwdState_16u32f;
-typedef struct sWTInvState_32f IppsWTInvState_32f;
-typedef struct sWTInvState_32f8u IppsWTInvState_32f8u;
-typedef struct sWTInvState_32f16s IppsWTInvState_32f16s;
-typedef struct sWTInvState_32f16u IppsWTInvState_32f16u;
-
-typedef struct IIRState_32f IppsIIRState_32f;
-typedef struct IIRState_32fc IppsIIRState_32fc;
-typedef struct IIRState32f_16s IppsIIRState32f_16s;
-typedef struct IIRState32fc_16sc IppsIIRState32fc_16sc;
-typedef struct IIRState_64f IppsIIRState_64f;
-typedef struct IIRState_64fc IppsIIRState_64fc;
-typedef struct IIRState64f_32f IppsIIRState64f_32f;
-typedef struct IIRState64fc_32fc IppsIIRState64fc_32fc;
-typedef struct IIRState64f_32s IppsIIRState64f_32s;
-typedef struct IIRState64fc_32sc IppsIIRState64fc_32sc;
-typedef struct IIRState64f_16s IppsIIRState64f_16s;
-typedef struct IIRState64fc_16sc IppsIIRState64fc_16sc;
-
-typedef struct FIRSpec_32f IppsFIRSpec_32f;
-typedef struct FIRSpec_64f IppsFIRSpec_64f;
-typedef struct FIRSpec_32fc IppsFIRSpec_32fc;
-typedef struct FIRSpec_64fc IppsFIRSpec_64fc;
-typedef struct FIRSpec32f_32fc IppsFIRSpec32f_32fc;
-
-typedef struct FIRLMSState_32f IppsFIRLMSState_32f;
-typedef struct FIRLMSState32f_16s IppsFIRLMSState32f_16s;
-
-typedef struct HilbertSpec IppsHilbertSpec;
-
-typedef struct FIRSparseState_32f IppsFIRSparseState_32f;
-typedef struct IIRSparseState_32f IppsIIRSparseState_32f;
-
-typedef struct ResamplingPolyphase_16s IppsResamplingPolyphase_16s;
-typedef struct ResamplingPolyphaseFixed_16s IppsResamplingPolyphaseFixed_16s;
-typedef struct ResamplingPolyphase_32f IppsResamplingPolyphase_32f;
-typedef struct ResamplingPolyphaseFixed_32f IppsResamplingPolyphaseFixed_32f;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippIP domain specific definitions */
-/*****************************************************************************/
-#define IPP_TEMPORAL_COPY 0x0
-#define IPP_NONTEMPORAL_STORE 0x01
-#define IPP_NONTEMPORAL_LOAD 0x02
-
-typedef int IppEnum;
-
-#define IPP_DEG_TO_RAD( deg ) ( (deg)/180.0 * IPP_PI )
-
-typedef enum {
- ippiNormNone = 0x00000000, /* default */
- ippiNorm = 0x00000100, /* normalized form */
- ippiNormCoefficient = 0x00000200, /* correlation coefficient in the range [-1.0 ... 1.0] */
- ippiNormMask = 0x0000FF00
-} IppiNormOp;
-
-typedef enum {
- ippiROIFull = 0x00000000,
- ippiROIValid = 0x00010000,
- ippiROISame = 0x00020000,
- ippiROIMask = 0x00FF0000
-} IppiROIShape;
-
-typedef enum {
- ippC0 = 0,
- ippC1 = 1,
- ippC2 = 2,
- ippC3 = 3,
- ippC4 = 4,
- ippP2 = 5,
- ippP3 = 6,
- ippP4 = 7,
- ippAC1 = 8,
- ippAC4 = 9,
- ippA0C4 = 10,
- ippAP4 = 11
-} IppChannels;
-
-typedef enum _IppiBorderType {
- ippBorderRepl = 1,
- ippBorderWrap = 2,
- ippBorderMirror = 3, /* left border: 012... -> 21012... */
- ippBorderMirrorR = 4, /* left border: 012... -> 210012... */
- ippBorderDefault = 5,
- ippBorderConst = 6,
- ippBorderTransp = 7,
-
- /* Flags to use source image memory pixels from outside of the border in particular directions */
- ippBorderInMemTop = 0x0010,
- ippBorderInMemBottom = 0x0020,
- ippBorderInMemLeft = 0x0040,
- ippBorderInMemRight = 0x0080,
- ippBorderInMem = ippBorderInMemLeft|ippBorderInMemTop|ippBorderInMemRight|ippBorderInMemBottom,
-
- /* Flags to use source image memory pixels from outside of the border for first stage only in multi-stage filters */
- ippBorderFirstStageInMemTop = 0x0100,
- ippBorderFirstStageInMemBottom = 0x0200,
- ippBorderFirstStageInMemLeft = 0x0400,
- ippBorderFirstStageInMemRight = 0x0800,
- ippBorderFirstStageInMem = ippBorderFirstStageInMemLeft|ippBorderFirstStageInMemTop|ippBorderFirstStageInMemRight|ippBorderFirstStageInMemBottom
-} IppiBorderType;
-
-typedef enum {
- ippAxsHorizontal,
- ippAxsVertical,
- ippAxsBoth,
- ippAxs45,
- ippAxs135
-} IppiAxis;
-
-typedef struct {
- int x;
- int y;
- int width;
- int height;
-} IppiRect;
-
-typedef struct {
- int x;
- int y;
-} IppiPoint;
-
-typedef struct {
- int width;
- int height;
-} IppiSize;
-
-typedef struct {
- Ipp32f x;
- Ipp32f y;
-} IppiPoint_32f;
-
-typedef enum _IppiMaskSize {
- ippMskSize1x3 = 13,
- ippMskSize1x5 = 15,
- ippMskSize3x1 = 31,
- ippMskSize3x3 = 33,
- ippMskSize5x1 = 51,
- ippMskSize5x5 = 55
-} IppiMaskSize;
-
-enum {
- IPPI_INTER_NN = 1,
- IPPI_INTER_LINEAR = 2,
- IPPI_INTER_CUBIC = 4,
- IPPI_INTER_CUBIC2P_BSPLINE, /* two-parameter cubic filter (B=1, C=0) */
- IPPI_INTER_CUBIC2P_CATMULLROM, /* two-parameter cubic filter (B=0, C=1/2) */
- IPPI_INTER_CUBIC2P_B05C03, /* two-parameter cubic filter (B=1/2, C=3/10) */
- IPPI_INTER_SUPER = 8,
- IPPI_INTER_LANCZOS = 16,
- IPPI_ANTIALIASING = (1 << 29),
- IPPI_SUBPIXEL_EDGE = (1 << 30),
- IPPI_SMOOTH_EDGE = IPP_MIN_32S /* GCC gives warning for (1 << 31) definition */
-};
-
-typedef enum {
- ippNearest = IPPI_INTER_NN,
- ippLinear = IPPI_INTER_LINEAR,
- ippCubic = IPPI_INTER_CUBIC2P_CATMULLROM,
- ippLanczos = IPPI_INTER_LANCZOS,
- ippHahn = 0,
- ippSuper = IPPI_INTER_SUPER
-} IppiInterpolationType;
-
-typedef enum {
- ippPolyphase_1_2,
- ippPolyphase_3_5,
- ippPolyphase_2_3,
- ippPolyphase_7_10,
- ippPolyphase_3_4
-} IppiFraction;
-
-enum {
- IPP_FASTN_ORIENTATION = 0x0001,
- IPP_FASTN_NMS = 0x0002,
- IPP_FASTN_CIRCLE = 0X0004,
- IPP_FASTN_SCORE_MODE0 = 0X0020
-};
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum {
- ippAlphaOver,
- ippAlphaIn,
- ippAlphaOut,
- ippAlphaATop,
- ippAlphaXor,
- ippAlphaPlus,
- ippAlphaOverPremul,
- ippAlphaInPremul,
- ippAlphaOutPremul,
- ippAlphaATopPremul,
- ippAlphaXorPremul,
- ippAlphaPlusPremul
-} IppiAlphaType;
-
-typedef struct DeconvFFTState_32f_C1R IppiDeconvFFTState_32f_C1R;
-typedef struct DeconvFFTState_32f_C3R IppiDeconvFFTState_32f_C3R;
-typedef struct DeconvLR_32f_C1R IppiDeconvLR_32f_C1R;
-typedef struct DeconvLR_32f_C3R IppiDeconvLR_32f_C3R;
-
-typedef enum {
- ippiFilterBilateralGauss = 100,
- ippiFilterBilateralGaussFast = 101
-} IppiFilterBilateralType;
-
-typedef struct FilterBilateralSpec IppiFilterBilateralSpec;
-
-typedef enum {
- ippDistNormL1 = 0x00000002,
- ippDistNormL2 = 0x00000004
-} IppiDistanceMethodType;
-
-typedef enum {
- ippResizeFilterHann,
- ippResizeFilterLanczos
-} IppiResizeFilterType;
-
-typedef struct ResizeFilterState IppiResizeFilterState;
-
-typedef struct {
- Ipp32u borderLeft;
- Ipp32u borderTop;
- Ipp32u borderRight;
- Ipp32u borderBottom;
-} IppiBorderSize;
-
-typedef enum {
- ippWarpForward,
- ippWarpBackward
-} IppiWarpDirection;
-
-typedef enum {
- ippWarpAffine,
- ippWarpPerspective,
- ippWarpBilinear
-} IppiWarpTransformType;
-
-
-typedef struct ResizeSpec_32f IppiResizeSpec_32f;
-typedef struct ResizeYUV422Spec IppiResizeYUV422Spec;
-typedef struct ResizeYUV420Spec IppiResizeYUV420Spec;
-
-typedef struct ResizeSpec_64f IppiResizeSpec_64f;
-
-typedef struct IppiWarpSpec IppiWarpSpec;
-
-typedef struct FilterBorderSpec IppiFilterBorderSpec;
-
-typedef struct ThresholdAdaptiveSpec IppiThresholdAdaptiveSpec;
-
-typedef struct HistogramSpec IppiHistogramSpec;
-
-typedef struct {
- int cvCompatible; /* openCV compatible output format */
- int cellSize; /* squre cell size (pixels) */
- int blockSize; /* square block size (pixels) */
- int blockStride; /* block displacement (the same for x- and y- directions) */
- int nbins; /* required number of bins */
- Ipp32f sigma; /* gaussian factor of HOG block weights */
- Ipp32f l2thresh; /* normalization factor */
- IppiSize winSize; /* detection window size (pixels) */
-} IppiHOGConfig;
-
-typedef struct FFT2DSpec_C_32fc IppiFFTSpec_C_32fc;
-typedef struct FFT2DSpec_R_32f IppiFFTSpec_R_32f;
-
-typedef struct DFT2DSpec_C_32fc IppiDFTSpec_C_32fc;
-typedef struct DFT2DSpec_R_32f IppiDFTSpec_R_32f;
-
-typedef struct DCT2DFwdSpec_32f IppiDCTFwdSpec_32f;
-typedef struct DCT2DInvSpec_32f IppiDCTInvSpec_32f;
-
-typedef struct iWTFwdSpec_32f_C1R IppiWTFwdSpec_32f_C1R;
-typedef struct iWTInvSpec_32f_C1R IppiWTInvSpec_32f_C1R;
-typedef struct iWTFwdSpec_32f_C3R IppiWTFwdSpec_32f_C3R;
-typedef struct iWTInvSpec_32f_C3R IppiWTInvSpec_32f_C3R;
-
-typedef struct MomentState64f IppiMomentState_64f;
-typedef Ipp64f IppiHuMoment_64f[7];
-
-typedef struct LUT_Spec IppiLUT_Spec;
-
-#define IPP_HOG_MAX_CELL (16) /* max size of CELL */
-#define IPP_HOG_MAX_BLOCK (64) /* max size of BLOCK */
-#define IPP_HOG_MAX_BINS (16) /* max number of BINS */
-
-typedef struct _ipHOG IppiHOGSpec;
-
-#endif /* _OWN_BLDPCS */
-
-
- /**** Below are 3D Image (Volume) Processing specific definitions ****/
-
-typedef struct {
- int width;
- int height;
- int depth;
-} IpprVolume;
-
-typedef struct {
- int x;
- int y;
- int z;
- int width;
- int height;
- int depth;
-} IpprCuboid;
-
-typedef struct {
- int x;
- int y;
- int z;
-} IpprPoint;
-
-/*****************************************************************************/
-/* Below are ippCV domain specific definitions */
-/*****************************************************************************/
-
-typedef enum _IppiDifferentialKernel
-{
- ippFilterSobelVert,
- ippFilterSobelHoriz,
- ippFilterSobel,
- ippFilterScharrVert,
- ippFilterScharrHoriz,
- ippFilterScharr,
- ippFilterCentralDiffVert,
- ippFilterCentralDiffHoriz,
- ippFilterCentralDiff
-}IppiDifferentialKernel;
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum _IppiKernelType {
- ippKernelSobel = 0,
- ippKernelScharr = 1,
- ippKernelSobelNeg = 2
-} IppiKernelType;
-
-typedef enum _IppiNorm {
- ippiNormInf = 0,
- ippiNormL1 = 1,
- ippiNormL2 = 2,
- ippiNormFM = 3
-} IppiNorm;
-
-typedef struct ipcvMorphState IppiMorphState;
-typedef struct ipcvMorphStateL IppiMorphStateL;
-typedef struct ipcvMorphAdvState IppiMorphAdvState;
-typedef struct ipcvMorphAdvStateL IppiMorphAdvStateL;
-typedef struct ipcvMorphGrayState_8u IppiMorphGrayState_8u;
-typedef struct ipcvMorphGrayState_8uL IppiMorphGrayState_8uL;
-typedef struct ipcvMorphGrayState_32f IppiMorphGrayState_32f;
-typedef struct ipcvMorphGrayState_32fL IppiMorphGrayState_32fL;
-
-typedef struct ipcvConvState IppiConvState;
-
-typedef struct _IppiConnectedComp {
- Ipp64f area; /* area of the segmented component */
- Ipp64f value[3];/* gray scale value of the segmented component */
- IppiRect rect; /* bounding rectangle of the segmented component */
-} IppiConnectedComp;
-
-typedef struct PyramidState IppiPyramidState;
-typedef struct FilterSeparableSpec IppiFilterSeparableSpec;
-
-typedef IppiPyramidState IppiPyramidDownState_8u_C1R;
-typedef IppiPyramidState IppiPyramidDownState_16u_C1R;
-typedef IppiPyramidState IppiPyramidDownState_32f_C1R;
-typedef IppiPyramidState IppiPyramidDownState_8u_C3R;
-typedef IppiPyramidState IppiPyramidDownState_16u_C3R;
-typedef IppiPyramidState IppiPyramidDownState_32f_C3R;
-typedef IppiPyramidState IppiPyramidUpState_8u_C1R;
-typedef IppiPyramidState IppiPyramidUpState_16u_C1R;
-typedef IppiPyramidState IppiPyramidUpState_32f_C1R;
-typedef IppiPyramidState IppiPyramidUpState_8u_C3R;
-typedef IppiPyramidState IppiPyramidUpState_16u_C3R;
-typedef IppiPyramidState IppiPyramidUpState_32f_C3R;
-
-
-typedef struct _IppiPyramid {
- Ipp8u **pImage;
- IppiSize *pRoi;
- Ipp64f *pRate;
- int *pStep;
- Ipp8u *pState;
- int level;
-} IppiPyramid;
-
-typedef struct OptFlowPyrLK IppiOptFlowPyrLK;
-
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_8u_C1R;
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_16u_C1R;
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_32f_C1R;
-
-typedef struct ipcvHaarClassifier_32f IppiHaarClassifier_32f;
-typedef struct ipcvHaarClassifier_32s IppiHaarClassifier_32s;
-
-typedef struct ipcvFGHistogramState_8u_C1R IppFGHistogramState_8u_C1R;
-typedef struct ipcvFGHistogramState_8u_C3R IppFGHistogramState_8u_C3R;
-
-typedef struct ipcvFGGaussianState_8u_C1R IppFGGaussianState_8u_C1R;
-typedef struct ipcvFGGaussianState_8u_C3R IppFGGaussianState_8u_C3R;
-
-typedef enum _IppiInpaintFlag {
- IPP_INPAINT_TELEA = 0,
- IPP_INPAINT_NS = 1
-} IppiInpaintFlag;
-
-typedef struct ippcvFilterGaussianSpec IppFilterGaussianSpec;
-
-typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C1R;
-typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C3R;
-
-typedef struct HoughProbSpec IppiHoughProbSpec;
-
-typedef struct FastNSpec IppiFastNSpec;
-
-typedef struct _IppiCornerFastN {
- int x;
- int y;
- int cornerType;
- int orientation;
- float angle;
- float score;
-} IppiCornerFastN;
-
-typedef struct FGMMState_8u_C3R IppFGMMState_8u_C3R;
-
-typedef struct
-{
- unsigned int numFrames;
- unsigned int maxNGauss;
- Ipp32f varInit;
- Ipp32f varMin;
- Ipp32f varMax;
- Ipp32f varWBRatio;
- Ipp32f bckgThr;
- Ipp32f varNGRatio;
- Ipp32f reduction;
- Ipp8u shadowValue;
- char shadowFlag;
- Ipp32f shadowRatio;
-} IppFGMModel;
-
-#endif /* _OWN_BLDPCS */
-
-#define IPP_SEGMENT_QUEUE 0x01
-#define IPP_SEGMENT_DISTANCE 0x02
-#define IPP_SEGMENT_BORDER_4 0x40
-#define IPP_SEGMENT_BORDER_8 0x80
-
-#define IPP_TRUNC(a,b) ((a)&~((b)-1))
-#define IPP_APPEND(a,b) (((a)+(b)-1)&~((b)-1))
-
-/*****************************************************************************/
-/* Below are ippCC domain specific definitions */
-/*****************************************************************************/
-enum {
- IPP_UPPER = 1,
- IPP_LEFT = 2,
- IPP_CENTER = 4,
- IPP_RIGHT = 8,
- IPP_LOWER = 16,
- IPP_UPPER_LEFT = 32,
- IPP_UPPER_RIGHT = 64,
- IPP_LOWER_LEFT = 128,
- IPP_LOWER_RIGHT = 256
-};
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum {
- ippDitherNone,
- ippDitherFS,
- ippDitherJJN,
- ippDitherStucki,
- ippDitherBayer
-} IppiDitherType;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippCH domain specific definitions */
-/*****************************************************************************/
-
-#if !defined( _OWN_BLDPCS )
-
-typedef struct {
- void *pFind;
- int lenFind;
-} IppRegExpFind;
-
-typedef struct RegExpState IppRegExpState;
-
-typedef enum {
- ippFmtASCII = 0,
- ippFmtUTF8
-} IppRegExpFormat;
-
-typedef struct RegExpReplaceState IppRegExpReplaceState;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippDC domain specific definitions */
-/*****************************************************************************/
-
-#if !defined ( _OWN_BLDPCS )
-
-typedef struct MTFState_8u IppMTFState_8u;
-
-typedef enum {
- ippBWTItohTanakaLimSort,
- ippBWTItohTanakaUnlimSort,
- ippBWTSuffixSort,
- ippBWTAutoSort
-} IppBWTSortAlgorithmHint;
-
-typedef struct LZSSState_8u IppLZSSState_8u;
-
-typedef struct LZ77State_8u IppLZ77State_8u;
-typedef enum{
- IppLZ77FastCompr,
- IppLZ77AverageCompr,
- IppLZ77BestCompr
-} IppLZ77ComprLevel;
-typedef enum{
- IppLZ77NoChcksm,
- IppLZ77Adler32,
- IppLZ77CRC32
-} IppLZ77Chcksm;
-typedef enum {
- IppLZ77NoFlush,
- IppLZ77SyncFlush,
- IppLZ77FullFlush,
- IppLZ77FinishFlush
-} IppLZ77Flush;
-typedef struct IppLZ77Pairs_16u {
- Ipp16u length;
- Ipp16u offset;
-} IppLZ77Pair;
-typedef enum {
- IppLZ77StatusInit,
- IppLZ77StatusLZ77Process,
- IppLZ77StatusHuffProcess,
- IppLZ77StatusFinal
-} IppLZ77DeflateStatus;
-typedef enum {
- IppLZ77UseFixed,
- IppLZ77UseDynamic,
- IppLZ77UseStored
-} IppLZ77HuffMode;
-typedef enum {
- IppLZ77InflateStatusInit,
- IppLZ77InflateStatusHuffProcess,
- IppLZ77InflateStatusLZ77Process,
- IppLZ77InflateStatusFinal
-} IppLZ77InflateStatus;
-
-typedef struct IppInflateState {
- const Ipp8u* pWindow; /* pointer to the sliding window
- (the dictionary for the LZ77 algorithm) */
- unsigned int winSize; /* size of the sliding window */
- unsigned int tableType; /* type of Huffman code tables
- (for example, 0 - tables for Fixed Huffman codes) */
- unsigned int tableBufferSize; /* (ENOUGH = 2048) * (sizeof(code) = 4) -
- sizeof(IppInflateState) */
-} IppInflateState;
-
-typedef enum { /* this type is used as a translator of the inflate_mode type from zlib */
- ippTYPE,
- ippLEN,
- ippLENEXT
-} IppInflateMode;
-
-typedef struct {
- Ipp16u freq;
- Ipp16u code;
-} IppDeflateFreqTable;
-
-typedef struct {
- Ipp16u code;
- Ipp16u len;
-} IppDeflateHuffCode;
-
-typedef struct RLEState_BZ2 IppRLEState_BZ2;
-
-typedef struct EncodeHuffState_BZ2 IppEncodeHuffState_BZ2;
-
-typedef struct DecodeHuffState_BZ2 IppDecodeHuffState_BZ2;
-
-typedef enum {
- IppLZO1XST, /* Single-threaded, generic LZO-compatible*/
- IppLZO1XMT /* Multi-threaded */
-} IppLZOMethod ;
-
-typedef struct LZOState_8u IppLZOState_8u;
-
-#endif /* _OWN_BLDPCS */
-
-/* /////////////////////////////////////////////////////////////////////////////
-// The following enumerator defines a status of Intel(R) IPP operations
-// negative value means error
-*/
- /* errors */
-#define ippStsCpuNotSupportedErr -9999/* The target CPU is not supported. */
-#define ippStsInplaceModeNotSupportedErr -9998/* The inplace operation is currently not supported. */
-
- /* ippCrypto specific statuses - any changes MUST be done in both repositories -
- IPP & ippCrypto - don't use sts range 1000-2000 - reserved for Crypto */
-
-#define ippStsIIRIIRLengthErr -234 /* Vector length for IIRIIR function is less than 3*(IIR order) */
-#define ippStsWarpTransformTypeErr -233 /* The warp transform type is illegal */
-#define ippStsExceededSizeErr -232 /* Requested size exceeded the maximum supported ROI size */
-#define ippStsWarpDirectionErr -231 /* The warp transform direction is illegal */
-#define ippStsFilterTypeErr -230 /* The filter type is incorrect or not supported */
-#define ippStsNormErr -229 /* The norm is incorrect or not supported */
-#define ippStsAlgTypeErr -228 /* Algorithm type is not supported. */
-#define ippStsMisalignedOffsetErr -227 /* The offset is not aligned with an element. */
-#define ippStsBorderErr -225 /* Illegal value for border type.*/
-#define ippStsDitherTypeErr -224 /* Dithering type is not supported. */
-#define ippStsUnknownStatusCodeErr -216 /* Unknown status code. */
-#define ippStsLzoBrokenStreamErr -214 /* LZO safe decompression function cannot decode LZO stream.*/
-#define ippStsRoundModeNotSupportedErr -213 /* Rounding mode is not supported. */
-#define ippStsDecimateFractionErr -212 /* Fraction in Decimate is not supported. */
-#define ippStsWeightErr -211 /* Incorrect value for weight. */
-#define ippStsQualityIndexErr -210 /* Cannot calculate the quality index for an image filled with a constant. */
-#define ippStsIIRPassbandRippleErr -209 /* Ripple in passband for Chebyshev1 design is less than zero, equal to zero, or greater than 29. */
-#define ippStsFilterFrequencyErr -208 /* Cutoff frequency of filter is less than zero, equal to zero, or greater than 0.5. */
-#define ippStsIIRGenOrderErr -206 /* Order of the IIR filter for design is less than 1, or greater than 12. */
-#define ippStsConvergeErr -205 /* The algorithm does not converge. */
-#define ippStsSizeMatchMatrixErr -204 /* The sizes of the source matrices are unsuitable. */
-#define ippStsCountMatrixErr -203 /* Count value is less than or equal to zero. */
-#define ippStsRoiShiftMatrixErr -202 /* RoiShift value is negative or not divisible by the size of the data type. */
-#define ippStsSrcDataErr -200 /* The source buffer contains unsupported data.*/
-#define ippStsSingularErr -195 /* Matrix is singular. */
-#define ippStsSparseErr -194 /* Positions of taps are not in ascending order, or are negative, or repetitive. */
-#define ippStsRegExpOptionsErr -190 /* RegExp: Options for the pattern are incorrect. */
-#define ippStsRegExpErr -189 /* RegExp: The structure pRegExpState contains incorrect data. */
-#define ippStsRegExpMatchLimitErr -188 /* RegExp: The match limit is exhausted. */
-#define ippStsRegExpQuantifierErr -187 /* RegExp: Incorrect quantifier. */
-#define ippStsRegExpGroupingErr -186 /* RegExp: Incorrect grouping. */
-#define ippStsRegExpBackRefErr -185 /* RegExp: Incorrect back reference. */
-#define ippStsRegExpChClassErr -184 /* RegExp: Incorrect character class. */
-#define ippStsRegExpMetaChErr -183 /* RegExp: Incorrect metacharacter. */
-#define ippStsStrideMatrixErr -182 /* Stride value is not positive or not divisible by the size of the data type. */
-#define ippStsNoiseRangeErr -125 /* Noise value for Wiener Filter is out of range. */
-#define ippStsNotEvenStepErr -108 /* Step value is not pixel multiple. */
-#define ippStsHistoNofLevelsErr -107 /* Number of levels for histogram is less than 2. */
-#define ippStsLUTNofLevelsErr -106 /* Number of levels for LUT is less than 2. */
-#define ippStsChannelOrderErr -60 /* Incorrect order of the destination channels. */
-#define ippStsDataTypeErr -59 /* Data type is incorrect or not supported. */
-#define ippStsQuadErr -58 /* The quadrangle is nonconvex or degenerates into triangle, line, or point */
-#define ippStsRectErr -57 /* Size of the rectangle region is less than, or equal to 1. */
-#define ippStsCoeffErr -56 /* Incorrect values for transformation coefficients. */
-#define ippStsNoiseValErr -55 /* Incorrect value for noise amplitude for dithering. */
-#define ippStsDitherLevelsErr -54 /* Number of dithering levels is out of range. */
-#define ippStsNumChannelsErr -53 /* Number of channels is incorrect, or not supported. */
-#define ippStsCOIErr -52 /* COI is out of range. */
-#define ippStsDivisorErr -51 /* Divisor is equal to zero, function is aborted. */
-#define ippStsAlphaTypeErr -50 /* Illegal type of image compositing operation. */
-#define ippStsGammaRangeErr -49 /* Gamma range bounds is less than, or equal to zero. */
-#define ippStsChannelErr -47 /* Illegal channel number. */
-#define ippStsToneMagnErr -46 /* Tone magnitude is less than, or equal to zero. */
-#define ippStsToneFreqErr -45 /* Tone frequency is negative, or greater than, or equal to 0.5. */
-#define ippStsTonePhaseErr -44 /* Tone phase is negative, or greater than, or equal to 2*PI. */
-#define ippStsTrnglMagnErr -43 /* Triangle magnitude is less than, or equal to zero. */
-#define ippStsTrnglFreqErr -42 /* Triangle frequency is negative, or greater than, or equal to 0.5. */
-#define ippStsTrnglPhaseErr -41 /* Triangle phase is negative, or greater than, or equal to 2*PI. */
-#define ippStsTrnglAsymErr -40 /* Triangle asymmetry is less than -PI, or greater than, or equal to PI. */
-#define ippStsHugeWinErr -39 /* Kaiser window is too big. */
-#define ippStsJaehneErr -38 /* Magnitude value is negative. */
-#define ippStsStrideErr -37 /* Stride value is less than the length of the row. */
-#define ippStsEpsValErr -36 /* Negative epsilon value. */
-#define ippStsWtOffsetErr -35 /* Invalid offset value for wavelet filter. */
-#define ippStsAnchorErr -34 /* Anchor point is outside the mask. */
-#define ippStsMaskSizeErr -33 /* Invalid mask size. */
-#define ippStsShiftErr -32 /* Shift value is less than zero. */
-#define ippStsSampleFactorErr -31 /* Sampling factor is less than,or equal to zero. */
-#define ippStsSamplePhaseErr -30 /* Phase value is out of range: 0 <= phase < factor. */
-#define ippStsFIRMRFactorErr -29 /* MR FIR sampling factor is less than, or equal to zero. */
-#define ippStsFIRMRPhaseErr -28 /* MR FIR sampling phase is negative, or greater than, or equal to the sampling factor. */
-#define ippStsRelFreqErr -27 /* Relative frequency value is out of range. */
-#define ippStsFIRLenErr -26 /* Length of a FIR filter is less than, or equal to zero. */
-#define ippStsIIROrderErr -25 /* Order of an IIR filter is not valid. */
-#define ippStsResizeFactorErr -24 /* Resize factor(s) is less than, or equal to zero. */
-#define ippStsInterpolationErr -23 /* Invalid interpolation mode. */
-#define ippStsMirrorFlipErr -22 /* Invalid flip mode. */
-#define ippStsMoment00ZeroErr -21 /* Moment value M(0,0) is too small to continue calculations. */
-#define ippStsThreshNegLevelErr -20 /* Negative value of the level in the threshold operation. */
-#define ippStsThresholdErr -19 /* Invalid threshold bounds. */
-#define ippStsFftFlagErr -18 /* Invalid value for the FFT flag parameter. */
-#define ippStsFftOrderErr -17 /* Invalid value for the FFT order parameter. */
-#define ippStsStepErr -16 /* Step value is not valid. */
-
-#ifndef IPPSTATUS_H__
-#define IPPSTATUS_H__
-typedef signed int IppStatus;
- /* start of common with ippCrypto part - any changes MUST be done in both repositories - IPP & ippCrypto */
- #define ippStsLoadDynErr -221 /* Error when loading the dynamic library. */
- #define ippStsLengthErr -15 /* Incorrect value for string length. */
- #define ippStsNotSupportedModeErr -14 /* The requested mode is currently not supported. */
- #define ippStsContextMatchErr -13 /* Context parameter does not match the operation. */
- #define ippStsScaleRangeErr -12 /* Scale bounds are out of range. */
- #define ippStsOutOfRangeErr -11 /* Argument is out of range, or point is outside the image. */
- #define ippStsDivByZeroErr -10 /* An attempt to divide by zero. */
- #define ippStsMemAllocErr -9 /* Memory allocated for the operation is not enough.*/
- #define ippStsNullPtrErr -8 /* Null pointer error. */
- #define ippStsRangeErr -7 /* Incorrect values for bounds: the lower bound is greater than the upper bound. */
- #define ippStsSizeErr -6 /* Incorrect value for data size. */
- #define ippStsBadArgErr -5 /* Incorrect arg/param of the function. */
- #define ippStsNoMemErr -4 /* Not enough memory for the operation. */
- #define ippStsErr -2 /* Unknown/unspecified error */
- /* no errors */
- #define ippStsNoErr 0 /* No errors. */
- /* warnings */
- #define ippStsNoOperation 1 /* No operation has been executed. */
- #define ippStsDivByZero 2 /* Zero value(s) for the divisor in the Div function. */
- #define ippStsWaterfall 43 /* Cannot load required library, waterfall is used. */
- /* end of common with ippCrypto part */
-#endif /* IPPSTATUS_H__ */
-
-#define ippStsSqrtNegArg 3 /* Negative value(s) for the argument in the Sqrt function. */
-#define ippStsInvZero 4 /* INF result. Zero value was met by InvThresh with zero level. */
-#define ippStsEvenMedianMaskSize 5 /* Even size of the Median Filter mask was replaced with the odd one. */
-#define ippStsLnZeroArg 7 /* Zero value(s) for the argument in the Ln function. */
-#define ippStsLnNegArg 8 /* Negative value(s) for the argument in the Ln function. */
-#define ippStsNanArg 9 /* Argument value is not a number. */
-#define ippStsOverflow 12 /* Overflow in the operation. */
-#define ippStsUnderflow 17 /* Underflow in the operation. */
-#define ippStsSingularity 18 /* Singularity in the operation. */
-#define ippStsDomain 19 /* Argument is out of the function domain.*/
-#define ippStsNonIntelCpu 20 /* The target CPU is not Genuine Intel. */
-#define ippStsCpuMismatch 21 /* Cannot set the library for the given CPU. */
-#define ippStsOvermuchStrings 26 /* Number of destination strings is more than expected. */
-#define ippStsOverlongString 27 /* Length of one of the destination strings is more than expected. */
-#define ippStsAffineQuadChanged 28 /* 4th vertex of destination quad is not equal to customer's one. */
-#define ippStsWrongIntersectROI 29 /* ROI has no intersection with the source or destination ROI. No operation. */
-#define ippStsWrongIntersectQuad 30 /* Quadrangle has no intersection with the source or destination ROI. No operation. */
-#define ippStsSrcSizeLessExpected 32 /* DC: Size of the source buffer is less than the expected one.*/
-#define ippStsDstSizeLessExpected 33 /* DC: Size of the destination buffer is less than the expected one. */
-#define ippStsDoubleSize 35 /* Width or height of image is odd. */
-#define ippStsNotSupportedCpu 36 /* The CPU is not supported. */
-#define ippStsUnknownCacheSize 37 /* The CPU is supported, but the size of the cache is unknown. */
-#define ippStsSymKernelExpected 38 /* The Kernel is not symmetric. */
-#define ippStsEvenMedianWeight 39 /* Even weight of the Weighted Median Filter is replaced with the odd one. */
-#define ippStsWrongIntersectVOI 40 /* VOI has no intersection with the source or destination volume. No operation. */
-#define ippStsNoAntialiasing 46 /* The mode does not support antialiasing. */
-#define ippStsRepetitiveSrcData 47 /* DC: The source data is too repetitive.*/
-#define ippStsSizeWrn 48 /* The size does not allow to perform full operation. */
-#define ippStsFeatureNotSupported 49 /* Current CPU doesn't support at least 1 of the desired features. */
-#define ippStsUnknownFeature 50 /* At least one of the desired features is unknown. */
-#define ippStsFeaturesCombination 51 /* Wrong combination of features. */
-#define ippStsAccurateModeNotSupported 52/* Accurate mode is not supported. */
-
-#define ippStsOk ippStsNoErr
-
-#endif
-
-#define ippRectInfinite ippiWarpGetRectInfinite()
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IPPTYPES_H__ */
diff --git a/ext/ipp/include/ippversion.h b/ext/ipp/include/ippversion.h
new file mode 100644
index 0000000..b97f5be
--- /dev/null
+++ b/ext/ipp/include/ippversion.h
@@ -0,0 +1,58 @@
+/*******************************************************************************
+* Copyright 2001-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
+// Purpose: Describes the Intel(R) IPP version
+//
+//
+*/
+
+
+#if !defined( IPPVERSION_H__ )
+#define IPPVERSION_H__
+
+#define IPP_VERSION_MAJOR 2019
+#define IPP_VERSION_MINOR 0
+#define IPP_VERSION_UPDATE 1
+
+#define IPP_VERSION_STR "2019.0.1 Gold"
+
+#endif /* IPPVERSION_H__ */
diff --git a/ext/ipp/ippcp.parts b/ext/ipp/ippcp.parts
index dd0e0d4..f9192d5 100644
--- a/ext/ipp/ippcp.parts
+++ b/ext/ipp/ippcp.parts
@@ -1,5 +1,6 @@
+# pylint:disable=I0011,W0401,W0614,C0103,E0602
############################################################################
-# Copyright 2016-2018 Intel Corporation
+# Copyright 2016-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,119 +14,102 @@
# See the License for the specific language governing permissions and
# limitations under the License.
############################################################################
-Import('*')
-
+"""Build configuration for Ipp Crypto
+"""
import os
+Import('*')
-env.PartVersion("2018.2.208")
+env.PartVersion("2019.0.1")
env.PartName("ippcp")
-ipp_libname = '${PART_SHORT_NAME}'
+ippcp_libname = '${PART_SHORT_NAME}'
-#includes to install
-install_headers = Pattern(src_dir='include/',
- includes=[
- 'ippcp.h',
- 'ippcpdefs.h',
- 'ippdefs.h',
- 'ippbase.h',
- 'ipptypes.h'
- ],
- excludes=[],
- recursive=True)
-source_headers = Pattern(src_dir='sources/include/',
- includes=['*'],
- excludes=[],
- recursive=True)
-# common headers, for SdkInclude
-common_headers = Pattern(src_dir='include/',
- includes=['ippdefs.h',
- 'ippbase.h',
- 'ipptypes.h'],
- excludes=[],
- recursive=True)
-#files
-ippcp_files = Pattern(src_dir='sources/ippcp/src/',
- includes=[
- '*.c',
- ],
- excludes=[],
- recursive=True)
+include_files = Pattern(
+ src_dir='include/', includes=['*.h'], excludes=[], recursive=True)
-ippdir = ''
+src_files = Pattern(
+ src_dir='sources/ippcp/',
+ includes=[
+ '*.c',
+ ],
+ excludes=[
+ 'pcparcfour*.c',
+ 'pcpmain.c',
+ '*sm2.c',
+ 'pcpsha1ca.c',
+ 'pcpaes*.c',
+ 'pcpdes*.c',
+ 'pcpdlp*.c',
+ 'pcphmac*.c',
+ 'pcpmd5*.c',
+ 'pcpng*.c',
+ 'pcpprime*.c',
+ 'pcprij*.c',
+ 'pcprsa*.c',
+ 'pcpsm3*.c',
+ 'pcpsms4*.c',
+ 'pcptdes*.c',
+ 'pcpmont_expbinbnu_sscm.c',
+ 'pcpmont_expwinbnu.c',
+ 'pcpmont_expwinbnu_sscm.c',
+ ],
+ recursive=False)
-#prebuild installs prebuild headers instead of src headers.
-#internal ipp includes src/primitives/ipp/
+env.Append(CPPPATH=[AbsDir('include/')])
+env.ExportCPPPATH([AbsDir('include/')])
env.Append(CPPPATH=[AbsDir('sources/include/')])
+env.Append(CPPPATH=[AbsDir('sources/ippcp/')])
+# ipp defines
+if env['TARGET_ARCH'] == 'x86':
+ env.Append(CPPDEFINES='_ARCH_IA32')
+else:
+ env.Append(CPPDEFINES='_ARCH_EM64T')
# env.Append(CPPDEFINES = '_IPP_BE') #only for BE targets
-
-#internal ipp includes src/primitives/ipp/
-env.Append(CPPPATH=[AbsDir('include/')])
-env.Append(CPPPATH=[AbsDir('sources/ippcp/src/')])
-#ipp defines
-env.Append(CPPDEFINES='_IPP_v50_') #required for all ippcp
-
env.Append(CPPDEFINES='_IPP_DEBUG') #enable function sanity checking
+env.Append(CPPDEFINES='_IPP_C99')
+env.Append(CPPDEFINES='_IPP_v50_')
+env.Append(CPPDEFINES='_PX')
+env.Append(CPPDEFINES='_ABL_')
-env.Append(CPPDEFINES=['_DISABLE_ALG_MD5_',
- '_DISABLE_ALG_SM3_']) #disable unused hash alg
-
-env.ExportCPPPATH([AbsDir('sources/include/')])
+env.Append(CPPDEFINES=['_DISABLE_ECP_SM2_'])
+env.Append(CPPDEFINES=[
+ '_DISABLE_ALG_SHA224_', '_DISABLE_ALG_SHA512_224_', '_DISABLE_ALG_MD5_',
+ '_DISABLE_ALG_SM3_'
+]) #disable unused hash algs
-if 'install_package' in env['MODE']:
- # All files at /ext/ipp/source/include
- env.InstallTopLevel(install_headers, sub_dir='ext/ipp/include')
- src_files = Pattern(src_dir='sources/ippcp/src/',
- includes=['*'],
- excludes=[''],
- recursive=True)
- env.InstallTopLevel(src_files, sub_dir='ext/ipp/sources/ippcp/src')
- this_file = Pattern(src_dir='.',
- includes=['ippcp.parts'],
- excludes=[],
- recursive=True)
- env.InstallTopLevel(this_file, sub_dir='ext/ipp/')
- makefile = Pattern(src_dir='./sources/ippcp',
- includes=['Makefile'],
- excludes=[],
- recursive=True)
- env.InstallTopLevel(makefile, sub_dir='ext/ipp/sources/ippcp')
- env.InstallTopLevel(source_headers, sub_dir='ext/ipp/sources/include')
-else:
- env.SdkInclude(install_headers)
- env.SdkInclude(common_headers)
- if 'use_commercial_ipp' in env['MODE']:
- env['CCOPY_LOGIC'] = 'copy'
- try:
- IPPCRYPTOROOT = os.environ['IPPCRYPTOROOT']
- except KeyError, e:
- env.PrintError("Necessary environment variable not set: ",
- e, show_stack=False)
- if env['TARGET_PLATFORM']['OS'] == 'win32':
- libpre = ''
- libpost = '.lib'
- IPP_TH_SYMBOL = 'mt'
- else:
- libpre = 'lib'
- libpost = '.a'
- IPP_TH_SYMBOL = ''
- if env['TARGET_PLATFORM']['ARCH'] == 'x86':
- archdir = 'ia32/'
- else:
- archdir = 'intel64/'
+env.SdkInclude(include_files)
- ippcp_libname = libpre + 'ippcp' + IPP_TH_SYMBOL + libpost
- ippcp_libdir = IPPCRYPTOROOT + '/lib/' + archdir
- env.SdkLib(ippcp_libdir + ippcp_libname)
+if 'use_commercial_ipp' in env['MODE']:
+ env['CCOPY_LOGIC'] = 'copy'
+ try:
+ IPPCRYPTOROOT = os.environ['IPPCRYPTOROOT']
+ except KeyError, e:
+ env.PrintError(
+ "Necessary environment variable not set: ", e, show_stack=False)
+ if env['TARGET_PLATFORM']['OS'] == 'win32':
+ libpre = ''
+ libpost = '.lib'
+ IPP_TH_SYMBOL = 'mt'
+ else:
+ libpre = 'lib'
+ libpost = '.a'
+ IPP_TH_SYMBOL = ''
+ if env['TARGET_PLATFORM']['ARCH'] == 'x86':
+ archdir = 'ia32/'
+ else:
+ archdir = 'intel64/'
+ ippcp_libname = libpre + 'ippcp' + IPP_TH_SYMBOL + libpost
+ ippcp_dir = IPPCRYPTOROOT + '/lib/' + archdir
+ env.SdkLib(ippcp_dir + ippcp_libname)
+else:
+ all_c_files = src_files.files()
+ if 'build_ipp_shared' in env['MODE']:
+ env.Append(CPPDEFINES=['IPP_W32DLL'])
+ outputs = env.SharedLibrary(ippcp_libname, all_c_files)
+ env.InstallTarget(outputs)
else:
- all_c_files = ippcp_files.files()
- if 'build_ipp_shared' in env['MODE']:
- env.Append(CPPDEFINES=['IPP_W32DLL'])
- outputs = env.SharedLibrary(ipp_libname, all_c_files)
- env.InstallTarget(outputs)
- else:
- outputs = env.Library(ipp_libname, all_c_files)
- env.SdkLib(outputs)
- if 'install_lib' in env['MODE']:
- env.InstallLib(outputs)
+ outputs = env.Library(ippcp_libname, all_c_files)
+ env.SdkLib(outputs)
+ if 'install_lib' in env['MODE']:
+ env.InstallLib(outputs)
diff --git a/ext/ipp/sources/include/asmdefs.inc b/ext/ipp/sources/include/asmdefs.inc
new file mode 100644
index 0000000..0dac3d2
--- /dev/null
+++ b/ext/ipp/sources/include/asmdefs.inc
@@ -0,0 +1,147 @@
+;===============================================================================
+; Copyright 2015-2018 Intel Corporation
+; All Rights Reserved.
+;
+; If this software was obtained under the Intel Simplified Software License,
+; the following terms apply:
+;
+; The source code, information and material ("Material") contained herein is
+; owned by Intel Corporation or its suppliers or licensors, and title to such
+; Material remains with Intel Corporation or its suppliers or licensors. The
+; Material contains proprietary information of Intel or its suppliers and
+; licensors. The Material is protected by worldwide copyright laws and treaty
+; provisions. No part of the Material may be used, copied, reproduced,
+; modified, published, uploaded, posted, transmitted, distributed or disclosed
+; in any way without Intel's prior express written permission. No license under
+; any patent, copyright or other intellectual property rights in the Material
+; is granted to or conferred upon you, either expressly, by implication,
+; inducement, estoppel or otherwise. Any license under such intellectual
+; property rights must be express and approved by Intel in writing.
+;
+; Unless otherwise agreed by Intel in writing, you may not remove or alter this
+; notice or any other notice embedded in Materials by Intel or Intel's
+; suppliers or licensors in any way.
+;
+;
+; If this software was obtained under the Apache License, Version 2.0 (the
+; "License"), the following terms apply:
+;
+; You may not use this file except in compliance with the License. You may
+; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+;
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;===============================================================================
+
+IFNDEF __ASMDEFS_INC__
+ __ASMDEFS_INC__=1
+
+_IPP_PX=0 ; pure C-code ia32
+_IPP_M5=1 ; Intel(R) Quark(TM) processor - ia32
+_IPP_W7=8 ; Intel(R) Streaming SIMD Extensions 2 - ia32
+_IPP_T7=16 ; Intel(R) Streaming SIMD Extensions 3 - ia32
+_IPP_V8=32 ; Supplemental Streaming SIMD Extensions 3 (SSSE3)
+_IPP_S8=33 ; SSSE3 + MOVBE instruction - ia32
+_IPP_P8=64 ; Intel(R) Streaming SIMD Extensions 4.2 - ia32
+_IPP_G9=128 ; Intel(R) Advanced Vector Extensions - ia32
+_IPP_H9=256 ; Intel(R) Advanced Vector Extensions 2 - ia32
+_IPP_I0=512 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon Phi(TM) processor (formerly Knight Landing) - ia32
+_IPP_S0=1024 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon(R) processor (formerly Skylake) - ia32
+
+_IPP32E_PX=_IPP_PX ; pure C-code x64
+_IPP32E_M7=32 ; Intel(R) Streaming SIMD Extensions 3 - intel64
+_IPP32E_U8=64 ; Supplemental Streaming SIMD Extensions 3 (SSSE3) - intel64
+_IPP32E_N8=65 ; SSSE3 + MOVBE instruction - intel64
+_IPP32E_Y8=128 ; Intel(R) Streaming SIMD Extensions 4.2 - intel64
+_IPP32E_E9=256 ; Intel(R) Advanced Vector Extensions - intel64
+_IPP32E_L9=512 ; Intel(R) Advanced Vector Extensions 2 - intel64
+_IPP32E_N0=1024 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon Phi(TM) processor (formerly Knight Landing) - intel64
+_IPP32E_K0=2048 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon(R) processor (formerly Skylake) - intel64
+
+_IPP=_IPP_PX
+_IPP32E=_IPP32E_PX
+
+
+IFDEF _M5 ; Intel(R) Quark(TM) processor - ia32
+ _IPP=_IPP_M5
+ELSEIFDEF _W7 ; Intel(R) Streaming SIMD Extensions 2 - ia32
+ _IPP=_IPP_W7
+ELSEIFDEF _T7 ; Intel(R) Streaming SIMD Extensions 3 - ia32
+ _IPP=_IPP_T7
+ELSEIFDEF _V8 ; Supplemental Streaming SIMD Extensions 3 (SSSE3)
+ _IPP=_IPP_V8
+ELSEIFDEF _S8 ; SSSE3 + MOVBE instruction - ia32
+ _IPP=_IPP_S8
+ELSEIFDEF _P8 ; Intel(R) Streaming SIMD Extensions 4.2 - ia32
+ _IPP=_IPP_P8
+ELSEIFDEF _G9 ; Intel(R) Advanced Vector Extensions - ia32
+ IPP_ALIGN_FACTOR EQU 32
+ _IPP=_IPP_G9
+ELSEIFDEF _H9 ; Intel(R) Advanced Vector Extensions 2 - ia32
+ IPP_ALIGN_FACTOR EQU 32
+ _IPP=_IPP_H9
+ELSEIFDEF _S0 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon(R) processor (formerly Skylake) - ia32
+ IPP_ALIGN_FACTOR EQU 64
+ _IPP=_IPP_S0
+ELSEIFDEF _M7 ; Intel(R) Streaming SIMD Extensions 3 - intel64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_M7
+ELSEIFDEF _U8 ; Supplemental Streaming SIMD Extensions 3 (SSSE3) - intel64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_U8
+ELSEIFDEF _N8 ; SSSE3 + MOVBE instruction - intel64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_N8
+ELSEIFDEF _Y8 ; Intel(R) Streaming SIMD Extensions 4.2 - intel64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_Y8
+ELSEIFDEF _E9 ; Intel(R) Advanced Vector Extensions - intel64
+ IPP_ALIGN_FACTOR EQU 32
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_E9
+ELSEIFDEF _L9 ; Intel(R) Advanced Vector Extensions 2 - intel64
+ IPP_ALIGN_FACTOR EQU 32
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_L9
+ELSEIFDEF _N0 ; Intel(R) Advanced Vector Extensions 512 (formerly Knights Landing) - intel64
+ IPP_ALIGN_FACTOR EQU 64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_N0
+ELSEIFDEF _K0 ; Intel(R) Advanced Vector Extensions 512 - Intel(R) Xeon(R) processor (formerly Skylake) - intel64
+ IPP_ALIGN_FACTOR EQU 64
+ _IPP=_IPP_PX
+ _IPP32E=_IPP32E_K0
+ELSE
+ _IPP=_IPP_PX ; pure C-code
+ENDIF
+
+IF (_IPP GT _IPP_H9)OR(_IPP32E GT _IPP32E_L9)
+ IPP_ALIGN_FACTOR EQU 64
+ELSEIF (_IPP GT _IPP_P8)OR(_IPP32E GT _IPP32E_Y8)
+ IPP_ALIGN_FACTOR EQU 32
+ELSE
+ IPP_ALIGN_FACTOR EQU 16
+ENDIF
+
+IFDEF LINUX32
+ IFNDEF OSX32
+%ECHO .section .note.GNU-stack,"",%progbits
+ ENDIF
+ENDIF
+
+IFDEF LINUX32E
+ IFNDEF OSXEM64T
+ IFNDEF _ARCH_KNC
+%ECHO .section .note.GNU-stack,"",%progbits
+ ENDIF
+ ENDIF
+ENDIF
+
+ENDIF ; IFNDEF __ASMDEFS_INC__
+
+;;;;;;;;;;;;;;;;;;;;;;;;;; End of file "asmdefs.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/ext/ipp/sources/include/dispatcher.h b/ext/ipp/sources/include/dispatcher.h
new file mode 100644
index 0000000..8203514
--- /dev/null
+++ b/ext/ipp/sources/include/dispatcher.h
@@ -0,0 +1,321 @@
+/*******************************************************************************
+* Copyright 2009-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+//
+// Intel(R) Integrated Performance Primitives (Intel(R) IPP) Cryptography
+//
+
+#ifndef __DISPATCHER_H__
+#define __DISPATCHER_H__
+
+#if defined( __cplusplus )
+extern "C" {
+#endif
+
+/*
+ Intel(R) IPP libraries and CPU features mask fitness. Implemented only for IA32 and Intel64 (emt)
+*/
+
+#if defined( _ARCH_IA32 )
+#define M5_FM ( 0 )
+#ifdef _IPP_QUARK
+#define PX_FM ( 0 )
+#else
+#define PX_FM ( ippCPUID_MMX | ippCPUID_SSE )
+#endif
+#define W7_FM ( PX_FM | ippCPUID_SSE2 )
+#define V8_FM ( W7_FM | ippCPUID_SSE3 | ippCPUID_SSSE3 )
+#define S8_FM ( V8_FM | ippCPUID_MOVBE )
+#define P8_FM ( V8_FM | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL | ippCPUID_SHA )
+#define G9_FM ( P8_FM | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C )
+#define H9_FM ( G9_FM | ippCPUID_MOVBE | ippCPUID_AVX2 | ippCPUID_ADCOX | ippCPUID_RDSEED | ippCPUID_PREFETCHW )
+#define I0_FM ( H9_FM | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512PF | ippCPUID_AVX512ER | ippAVX512_ENABLEDBYOS )
+#define S0_FM ( H9_FM | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512VL | ippCPUID_AVX512BW | ippCPUID_AVX512DQ | ippAVX512_ENABLEDBYOS )
+
+#elif defined (_ARCH_EM64T)
+
+#define PX_FM ( ippCPUID_MMX | ippCPUID_SSE | ippCPUID_SSE2 )
+#define M7_FM ( PX_FM | ippCPUID_SSE3 )
+#define U8_FM ( M7_FM | ippCPUID_SSSE3 )
+#define N8_FM ( U8_FM | ippCPUID_MOVBE )
+#define Y8_FM ( U8_FM | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL | ippCPUID_SHA )
+#define E9_FM ( Y8_FM | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C )
+#define L9_FM ( E9_FM | ippCPUID_MOVBE | ippCPUID_AVX2 | ippCPUID_ADCOX | ippCPUID_RDSEED | ippCPUID_PREFETCHW )
+#define N0_FM ( L9_FM | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512PF | ippCPUID_AVX512ER | ippAVX512_ENABLEDBYOS )
+#define K0_FM ( L9_FM | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512VL | ippCPUID_AVX512BW | ippCPUID_AVX512DQ | ippAVX512_ENABLEDBYOS )
+
+#elif defined (_ARCH_LRB2)
+ #define PX_FM ( ippCPUID_KNC )
+#else
+ #error undefined architecture
+#endif
+
+#define PX_MSK ( 0 )
+#define MMX_MSK ( ippCPUID_MMX )
+#define SSE_MSK ( MMX_MSK | ippCPUID_SSE )
+#define SSE2_MSK ( SSE_MSK | ippCPUID_SSE2 )
+#define SSE3_MSK ( SSE2_MSK | ippCPUID_SSE3 )
+#define SSSE3_MSK ( SSE3_MSK | ippCPUID_SSSE3 )
+#define ATOM_MSK ( SSE3_MSK | ippCPUID_SSSE3 | ippCPUID_MOVBE )
+#define SSE41_MSK ( SSSE3_MSK | ippCPUID_SSE41 )
+#define SSE42_MSK ( SSE41_MSK | ippCPUID_SSE42 )
+#define AVX_MSK ( SSE42_MSK | ippCPUID_AVX )
+#define AVX2_MSK ( AVX_MSK | ippCPUID_AVX2 )
+#define AVX3X_MSK ( AVX2_MSK | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512VL | ippCPUID_AVX512BW | ippCPUID_AVX512DQ )
+#define AVX3M_MSK ( AVX2_MSK | ippCPUID_AVX512F | ippCPUID_AVX512CD | ippCPUID_AVX512PF | ippCPUID_AVX512ER )
+
+#if defined( _ARCH_IA32 ) && !defined( OSX32 ) && !defined( ANDROID )
+ enum lib_enum {
+ LIB_W7=0, LIB_S8=1, LIB_P8=2, LIB_G9=3, LIB_H9=4, LIB_NOMORE
+ };
+ #define LIB_PX LIB_W7
+#elif defined( OSX32 )
+ enum lib_enum {
+ LIB_S8=0, LIB_P8=1, LIB_G9=2, LIB_H9=3, LIB_NOMORE
+ };
+ #define LIB_PX LIB_S8
+ #define LIB_W7 LIB_S8
+#elif defined( ANDROID ) && defined( _ARCH_IA32 )
+ enum lib_enum {
+ LIB_S8=0, LIB_P8=1, LIB_G9=2, LIB_H9=3, LIB_NOMORE
+ };
+ #define LIB_PX LIB_S8
+ #define LIB_W7 LIB_S8
+
+#elif defined( ANDROID ) && defined( _ARCH_EM64T )
+ enum lib_enum {
+ LIB_N8=0, LIB_Y8=1, LIB_E9=2, LIB_L9=3, LIB_NOMORE
+ };
+ #define LIB_PX LIB_N8
+ #define LIB_M7 LIB_N8
+ #define LIB_K0 LIB_L9
+ #define LIB_N0 LIB_L9
+
+#elif defined( _ARCH_EM64T ) && !defined( OSXEM64T ) && !defined( ANDROID ) && !defined( _WIN32E ) /* Linux* OS Intel64 supports N0 */
+ enum lib_enum {
+ LIB_M7=0, LIB_N8=1, LIB_Y8=2, LIB_E9=3, LIB_L9=4, LIB_N0=5, LIB_K0=6, LIB_NOMORE
+ };
+ #define LIB_PX LIB_M7
+#elif defined( _ARCH_EM64T ) && !defined( OSXEM64T ) && !defined( ANDROID ) /* Windows* OS Intel64 doesn't support N0 */
+ enum lib_enum {
+ LIB_M7=0, LIB_N8=1, LIB_Y8=2, LIB_E9=3, LIB_L9=4, LIB_K0=5, LIB_NOMORE
+ };
+ #define LIB_PX LIB_M7
+ #define LIB_N0 LIB_L9
+#elif defined( OSXEM64T )
+ enum lib_enum {
+ LIB_N8=0, LIB_Y8=1, LIB_E9=2, LIB_L9=3, LIB_K0=4, LIB_NOMORE
+ };
+ #define LIB_PX LIB_N8
+ #define LIB_M7 LIB_N8
+ #define LIB_N0 LIB_L9
+#elif defined( _ARCH_LRB2 )
+ enum lib_enum {
+ LIB_PX=0, LIB_B2=1, LIB_NOMORE
+ };
+ #define LIB_MIC LIB_B2
+#else
+ #error "lib_enum isn't defined!"
+#endif
+
+#if defined( _ARCH_IA32 )
+ #if defined( OSX32 ) /* OSX supports starting with Intel(R) architecture formerly codenamed Penryn only */
+ #define LIB_MMX LIB_S8
+ #define LIB_SSE LIB_S8
+ #define LIB_SSE2 LIB_S8
+ #define LIB_SSE3 LIB_S8
+ #define LIB_ATOM LIB_S8
+ #define LIB_SSSE3 LIB_S8
+ #define LIB_SSE41 LIB_S8
+ #define LIB_SSE42 LIB_P8
+ #define LIB_AVX LIB_G9
+ #define LIB_AVX2 LIB_H9
+ #define LIB_AVX3M LIB_H9 /* no ia32 library for Intel(R) Xeon Phi(TM) processor (formerly Knight Landing) */
+ #define LIB_AVX3X LIB_H9 /* no ia32 library for Intel(R) Xeon(R) processor (formerly Skylake) */
+ #else
+ #define LIB_MMX LIB_W7
+ #define LIB_SSE LIB_W7
+ #define LIB_SSE2 LIB_W7
+ #define LIB_SSE3 LIB_W7
+ #define LIB_ATOM LIB_S8
+ #define LIB_SSSE3 LIB_S8
+ #define LIB_SSE41 LIB_S8 /* P8 is oriented for new Intel Atom(R) processor (formerly Silvermont) */
+ #define LIB_SSE42 LIB_P8
+ #define LIB_AVX LIB_G9
+ #define LIB_AVX2 LIB_H9
+ #define LIB_AVX3M LIB_H9 /* no ia32 library for Intel(R) Xeon Phi(TM) processor (formerly Knight Landing) */
+ #define LIB_AVX3X LIB_H9 /* no ia32 library for Intel(R) Xeon(R) processor (formerly Skylake) */
+ #endif
+#elif defined (_ARCH_EM64T)
+ #if defined( OSXEM64T ) /* OSX supports starting PNR only */
+ #define LIB_MMX LIB_N8
+ #define LIB_SSE LIB_N8
+ #define LIB_SSE2 LIB_N8
+ #define LIB_SSE3 LIB_N8
+ #define LIB_ATOM LIB_N8
+ #define LIB_SSSE3 LIB_N8
+ #define LIB_SSE41 LIB_N8
+ #define LIB_SSE42 LIB_Y8
+ #define LIB_AVX LIB_E9
+ #define LIB_AVX2 LIB_L9
+ #define LIB_AVX3M LIB_L9
+ #define LIB_AVX3X LIB_K0
+ #else
+ #define LIB_MMX LIB_M7
+ #define LIB_SSE LIB_M7
+ #define LIB_SSE2 LIB_M7
+ #define LIB_SSE3 LIB_M7
+ #define LIB_ATOM LIB_N8
+ #define LIB_SSSE3 LIB_N8
+ #define LIB_SSE41 LIB_N8 /* Y8 is oriented for new Intel Atom(R) processor (formerly Silvermont) */
+ #define LIB_SSE42 LIB_Y8
+ #define LIB_AVX LIB_E9
+ #define LIB_AVX2 LIB_L9
+ #define LIB_AVX3M LIB_N0
+ #define LIB_AVX3X LIB_K0
+ #endif
+#elif defined (_ARCH_LRB2)
+ #define LIB_MIC LIB_B2
+#endif
+
+#if defined( _IPP_DYNAMIC )
+#if defined( _ARCH_IA32 )
+
+/* Describe Intel CPUs and libraries */
+typedef enum{CPU_W7=0, CPU_S8, CPU_P8, CPU_G9, CPU_H9, CPU_NOMORE} cpu_enum;
+typedef enum{DLL_W7=0, DLL_S8, DLL_P8, DLL_G9, DLL_H9, DLL_NOMORE} dll_enum;
+
+/* New cpu can use some libraries for old cpu */
+static const dll_enum dllUsage[][DLL_NOMORE+1] = {
+ /* DLL_H9, DLL_G9, DLL_P8, DLL_S8, DLL_W7, DLL_NOMORE */
+/*CPU_W7*/ { DLL_W7, DLL_NOMORE },
+/*CPU_S8*/ { DLL_S8, DLL_W7, DLL_NOMORE },
+/*CPU_P8*/ { DLL_P8, DLL_S8, DLL_W7, DLL_NOMORE },
+/*CPU_G9*/ { DLL_G9, DLL_P8, DLL_S8, DLL_W7, DLL_NOMORE },
+/*CPU_H9*/ { DLL_H9, DLL_G9, DLL_P8, DLL_S8, DLL_W7, DLL_NOMORE }
+};
+
+#elif defined (_ARCH_EM64T)
+/* Describe Intel CPUs and libraries */
+typedef enum{CPU_M7=0, CPU_N8, CPU_Y8, CPU_E9, CPU_L9, CPU_N0, CPU_K0, CPU_NOMORE} cpu_enum;
+typedef enum{DLL_M7=0, DLL_N8, DLL_Y8, DLL_E9, DLL_L9, DLL_N0, DLL_K0, DLL_NOMORE} dll_enum;
+
+/* New cpu can use some libraries for old cpu */
+static const dll_enum dllUsage[][DLL_NOMORE+1] = {
+ /* DLL_K0, DLL_N0, DLL_L9, DLL_E9, DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE */
+/*CPU_M7*/ { DLL_M7, DLL_NOMORE },
+/*CPU_N8*/ { DLL_N8, DLL_M7, DLL_NOMORE },
+/*CPU_Y8*/ { DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE },
+/*CPU_E9*/ { DLL_E9, DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE },
+/*CPU_L9*/ { DLL_L9, DLL_E9, DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE },
+/*CPU_N0*/ { DLL_N0, DLL_L9, DLL_E9, DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE },
+/*CPU_K0*/ { DLL_K0, DLL_N0, DLL_L9, DLL_E9, DLL_Y8, DLL_N8, DLL_M7, DLL_NOMORE }
+};
+
+#endif
+
+#if defined( _PCS )
+
+/* Names of the Intel libraries which can be loaded */
+#if defined ( _WIN32 ) && !defined( _WIN64 ) && !defined( _WIN32E )
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T(IPP_LIB_PREFIX()) _T("w7") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("s8") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("p8") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("g9") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("h9") _T(".dll")
+};
+#elif defined(linux32)
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("w7.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("s8.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("p8.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("g9.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("h9.so")
+};
+#elif defined( OSX32 )
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("s8") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("p8") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("g9") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("h9") _T(".dylib")
+};
+#elif defined( _WIN32E )
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T(IPP_LIB_PREFIX()) _T("m7") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("n8") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("y8") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("e9") _T(".dll"),
+ _T(IPP_LIB_PREFIX()) _T("l9") _T(".dll"), /* no support for N0 on win */
+ _T(IPP_LIB_PREFIX()) _T("k0") _T(".dll")
+};
+#elif defined( OSXEM64T )
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("n8") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("y8") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("e9") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("l9") _T(".dylib"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("k0") _T(".dylib")
+};
+#elif defined( linux32e )
+static const _TCHAR* dllNames[DLL_NOMORE] = {
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("m7.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("n8.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("y8.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("e9.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("l9.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("n0.so"),
+ _T("lib") _T(IPP_LIB_PREFIX()) _T("k0.so")
+};
+#endif
+
+#endif /* _PCS */
+
+#else /*_IPP_DYNAMIC */
+
+
+#endif
+
+
+#if defined( __cplusplus )
+}
+#endif
+
+#endif /* __DISPATCHER_H__ */
diff --git a/ext/ipp/sources/include/ia_32e.inc b/ext/ipp/sources/include/ia_32e.inc
new file mode 100644
index 0000000..b6e2e14
--- /dev/null
+++ b/ext/ipp/sources/include/ia_32e.inc
@@ -0,0 +1,4651 @@
+;===============================================================================
+; Copyright 2015-2018 Intel Corporation
+; All Rights Reserved.
+;
+; If this software was obtained under the Intel Simplified Software License,
+; the following terms apply:
+;
+; The source code, information and material ("Material") contained herein is
+; owned by Intel Corporation or its suppliers or licensors, and title to such
+; Material remains with Intel Corporation or its suppliers or licensors. The
+; Material contains proprietary information of Intel or its suppliers and
+; licensors. The Material is protected by worldwide copyright laws and treaty
+; provisions. No part of the Material may be used, copied, reproduced,
+; modified, published, uploaded, posted, transmitted, distributed or disclosed
+; in any way without Intel's prior express written permission. No license under
+; any patent, copyright or other intellectual property rights in the Material
+; is granted to or conferred upon you, either expressly, by implication,
+; inducement, estoppel or otherwise. Any license under such intellectual
+; property rights must be express and approved by Intel in writing.
+;
+; Unless otherwise agreed by Intel in writing, you may not remove or alter this
+; notice or any other notice embedded in Materials by Intel or Intel's
+; suppliers or licensors in any way.
+;
+;
+; If this software was obtained under the Apache License, Version 2.0 (the
+; "License"), the following terms apply:
+;
+; You may not use this file except in compliance with the License. You may
+; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+;
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;===============================================================================
+
+; Last version 04.12.04 for ML64 Version 8.00.41111 (PNI+x87+MMX(TM) technology supported)
+;
+; Bug for PMULUDQ fixed with MACRO substitution
+;
+; The latest version from 25.04.07: Kobby' mni macro substituted with IPP
+; realization (because of erroneous REX byte for addressing with sib byte,
+; high gpr set and scaling==1 - for instance [r8+r9]) also SNI support
+; added.
+;
+; 26.01.2009 - USES_XMM_AVX & REST_XMM_AVX added - 'v' prefix instructions
+; are used now for save/restore XMM and YMM registers + automatic "vzeroupper"
+; in REST_XMM_AVX macro
+;
+; 14.12.2009 - FMA macro added for AVX2.0 (ml10.0 support only)
+; 10.02.2012 - the "f" declared local in USES_GPR, RES_GPR and IFSAME_XMM macros to avoid possible conflict
+; 01.06.2012 - AVX2 vpsllvd/vq variable shifts added FMA macro fixed for ymm10-15 support
+; 11.03.2013 - BDW adcx/adox added
+.XLIST
+;.LISTALL
+;.LIST
+;.LISTIF
+;.LISTMACROALL
+
+include asmdefs.inc
+
+CurVer TEXTEQU @Version
+IF @Version GT 900
+ D_ML900 equ 1
+ELSE
+ ymmword equ oword
+ENDIF
+
+IF @Version GE 1100
+ ML1100 equ 1
+ENDIF
+
+IF @Version GE 1200
+ ML1200 equ 1
+ENDIF
+
+IF @Version GE 1400
+ ML1400 equ 1
+ENDIF
+
+IFNDEF LINUX32E
+ IFNDEF WIN32E
+ .ERR <Platform is not defined { LINUX32E or WIN32E }>
+ ECHO LINUX32E or WIN32E - Linux ABI (parameter passing in rdi, rsi, rdx, rcx, r8, r9...)
+ END
+ ENDIF
+ENDIF
+
+IFDEF LINUX32E
+ IFDEF STACK_ABI
+ IPP_ABI = 2
+ ELSE
+ IPP_ABI = 3
+ ENDIF
+ENDIF
+
+IFDEF WIN32E
+ IFDEF STACK_ABI
+ IPP_ABI = 1
+ ELSE
+ IPP_ABI = 0
+ ENDIF
+ENDIF
+
+IPPASM macro x:req, y:VARARG
+ IFDEF _OWN_MERGED_BLD
+ IF _IPP32E EQ _IPP32E_PX
+ @CatStr(<mx_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_M7
+ @CatStr(<m7_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_U8
+ @CatStr(<u8_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_N8
+ @CatStr(<n8_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_Y8
+ @CatStr(<y8_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_E9
+ @CatStr(<e9_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_L9
+ @CatStr(<l9_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_N0
+ @CatStr(<n0_>, <x>)
+ ENDIF
+ IF _IPP32E EQ _IPP32E_K0
+ @CatStr(<k0_>, <x>)
+ ENDIF
+ ELSE
+ @CatStr(<>, <x>)
+ ENDIF
+endm
+
+DEFINED MACRO symbol:REQ
+ IFDEF symbol
+ EXITM <-1>
+ ELSE
+ EXITM <0>
+ ENDIF
+ENDM
+
+
+IFSAME_GPR MACRO x, f
+ LOCAL y
+ FOR y,<rbx,rbp,r12,r13,r14,r15,RBX,RBP,R12,R13,R14,R15>
+ IFIDN <y>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF IPP_ABI LT 2
+ FOR y,<rsi,RSI,rdi,RDI>
+ IFIDN <y>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ENDM
+
+GPR_CUR textequ <>
+XMM_CUR textequ <>
+
+@ArgRev MACRO arglist:vararg
+ LOCAL txt, arg
+ txt TEXTEQU <>
+ FOR arg, <arglist>
+ txt CATSTR <arg>, <!,>, txt
+ ENDM
+ IF @SizeStr( %txt ) GT 0
+ txt SUBSTR txt, 1, @SizeStr( %txt ) - 1
+ ENDIF
+ txt CATSTR <!<>, txt, <!>>
+ EXITM txt
+ENDM
+
+USES_GPR MACRO z:vararg
+ LOCAL y, f
+ LOCAL_FRAME = 0
+ GPR_FRAME = 0
+ GPR_CUR textequ @ArgRev( z )
+ f = 0
+ FOR y,<z>
+ IFSAME_GPR y,f
+ IF f GT 0
+ GPR_FRAME = GPR_FRAME + 8
+ push y
+ .PUSHREG y
+ f = 0
+ ENDIF
+ ENDM
+ENDM
+
+REST_GPR MACRO z:vararg
+ LOCAL u, f
+ f = 0
+ %FOR u, GPR_CUR
+ IFSAME_GPR u,f
+ IF f GT 0
+ pop u
+ f = 0
+ ENDIF
+ ENDM
+ENDM
+
+IFSAME_XMM MACRO x, isFound
+ LOCAL y, isFound
+ isFound = 0
+ FOR y,<xmm6,XMM6,xmm7,XMM7,xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15>
+ IFIDN <y>,<x>
+ isFound = 1
+ EXITM
+ ENDIF
+ ENDM
+ENDM
+
+USES_XMM MACRO z:vararg
+ LOCAL y
+ XMM_CUR TEXTEQU <>
+ S_FRAME = 0
+ LOCAL_FRAME = ( LOCAL_FRAME + 15 ) AND (-16)
+ IF IPP_ABI LT 2
+ T_FRAME = 0
+ FOR y,<z>
+ IFSAME_XMM y, isFound
+ IF isFound GT 0
+ XMM_CUR CATSTR <y>, <!,>, XMM_CUR
+ T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ IF @SizeStr( %XMM_CUR ) GT 0
+ XMM_CUR SUBSTR XMM_CUR, 1, @SizeStr( %XMM_CUR ) - 1
+ ENDIF
+ XMM_CUR CATSTR <!<>, XMM_CUR, <!>>
+ IF (( T_FRAME GT 0 ) OR ( LOCAL_FRAME GT 0 ))
+ S_FRAME = T_FRAME + LOCAL_FRAME
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ ENDIF
+ IF S_FRAME GT 0
+ sub rsp,S_FRAME
+ .ALLOCSTACK S_FRAME
+ T_FRAME = LOCAL_FRAME
+ %FOR y, XMM_CUR
+ IFSAME_XMM y, isFound
+ IF isFound GT 0
+ movdqa [rsp+T_FRAME],y
+ .SAVEXMM128 y,T_FRAME
+ T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ ENDIF
+ ELSE
+ IF IPP_ABI EQ 2
+ S_FRAME = 48 + LOCAL_FRAME ;; 48 = 6 * 8 - stack frame for 6 register inputs
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ INP_FRAME = S_FRAME - 48 ;; for Linux32s-key stack-frame for 6 registers inputs...
+ ELSE
+ IF LOCAL_FRAME GT 0
+ S_FRAME = LOCAL_FRAME
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ ENDIF
+ ENDIF
+ IF S_FRAME GT 0
+ sub rsp,S_FRAME
+ ENDIF
+ ENDIF
+ENDM
+
+REST_XMM MACRO z:vararg
+ LOCAL y
+ IF IPP_ABI LT 2
+ IF S_FRAME GT 0
+ T_FRAME = LOCAL_FRAME
+ %FOR y, XMM_CUR
+ movdqa y,[rsp+T_FRAME]
+ T_FRAME = T_FRAME + 16
+ ENDM
+ add rsp,S_FRAME
+ ENDIF
+ ELSE
+ IF S_FRAME GT 0
+ add rsp,S_FRAME
+ ENDIF
+ ENDIF
+ IF _IPP32E GE _IPP32E_E9
+ IF _IPP32E NE _IPP32E_N0
+ vzeroupper
+ ENDIF
+ ENDIF
+ENDM
+
+
+SAVE_XMM textequ <!<xmm6,XMM6,xmm7,XMM7,xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15!>>
+SAVE_YMM textequ <!<ymm6,YMM6,ymm7,YMM7,ymm8,YMM8,ymm9,YMM9,ymm10,YMM10,ymm11,YMM11,ymm12,YMM12,ymm13,YMM13,ymm14,YMM14,ymm15,YMM15!>>
+
+IS_SAVEX MACRO x, f
+ f = 0
+ %FOR yrex,SAVE_XMM ; if xmm from 6-15 range and Windows - must be saved
+ IFIDN <yrex>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ENDM
+
+IS_SAVEY MACRO x, f
+ f = 0
+ %FOR yrex,SAVE_YMM ; if xmm from 6-15 range and Windows - must be saved
+ IFIDN <yrex>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ENDM
+
+USES_XMM_AVX MACRO z:vararg
+ LOCAL y, f
+ XMM_CUR TEXTEQU <>
+ S_FRAME = 0
+ LOCAL_FRAME = ( LOCAL_FRAME + 15 ) AND (-16)
+ IF IPP_ABI LT 2
+ T_FRAME = 0
+ FOR y,<z>
+ IS_SAVEX y, f
+ IF f GT 0
+ XMM_CUR CATSTR <y>, <!,>, XMM_CUR
+ T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ FOR y,<z>
+ IS_SAVEY y, f
+ IF f GT 0
+ XMM_CUR CATSTR <y>, <!,>, XMM_CUR
+ T_FRAME = T_FRAME + 32
+ ENDIF
+ ENDM
+ IF @SizeStr( %XMM_CUR ) GT 0
+ XMM_CUR SUBSTR XMM_CUR, 1, @SizeStr( %XMM_CUR ) - 1
+ ENDIF
+ XMM_CUR CATSTR <!<>, XMM_CUR, <!>>
+ IF (( T_FRAME GT 0 ) OR ( LOCAL_FRAME GT 0 ))
+ S_FRAME = T_FRAME + LOCAL_FRAME
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ ENDIF
+ IF S_FRAME GT 0
+ sub rsp,S_FRAME
+ .ALLOCSTACK S_FRAME
+ T_FRAME = LOCAL_FRAME
+ %FOR y, XMM_CUR
+ IS_SAVEX y, f
+ IF f GT 0
+ vmovdqa oword ptr [rsp+T_FRAME],y
+ .SAVEXMM128 y,T_FRAME
+ T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ %FOR y, XMM_CUR
+ IS_SAVEY y, f
+ IF f GT 0
+ vmovdqu ymmword ptr [rsp+T_FRAME], y
+ T_FRAME = T_FRAME + 32
+; vextractf128 oword ptr [rsp+T_FRAME],y,0
+; .SAVEXMM128 y,T_FRAME
+; T_FRAME = T_FRAME + 16
+; vextractf128 oword ptr [rsp+T_FRAME],y,1
+; .SAVEXMM128 y,T_FRAME
+; T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ ENDIF
+ ELSE
+ IF IPP_ABI EQ 2
+ S_FRAME = 48 + LOCAL_FRAME ;; 48 = 6 * 8 - stack frame for 6 register inputs
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ INP_FRAME = S_FRAME - 48 ;; for Linux32s-key stack-frame for 6 registers inputs...
+ ELSE
+ IF LOCAL_FRAME GT 0
+ S_FRAME = LOCAL_FRAME
+ IF (( S_FRAME + GPR_FRAME ) AND 8 ) EQ 0
+ S_FRAME = S_FRAME + 8
+ ENDIF
+ ENDIF
+ ENDIF
+ IF S_FRAME GT 0
+ sub rsp,S_FRAME
+ ENDIF
+ ENDIF
+ENDM
+
+REST_XMM_AVX MACRO z:vararg
+ LOCAL y, f
+ IF IPP_ABI LT 2
+ IF S_FRAME GT 0
+ T_FRAME = LOCAL_FRAME
+ %FOR y, XMM_CUR
+ IS_SAVEX y, f
+ IF f GT 0
+ vmovdqa y, oword ptr [rsp+T_FRAME]
+ T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ %FOR y, XMM_CUR
+ IS_SAVEY y, f
+ IF f GT 0
+ vmovdqu y, ymmword ptr [rsp+T_FRAME]
+ T_FRAME = T_FRAME + 32
+; vinsertf128 y,y,oword ptr [rsp+T_FRAME],0
+; T_FRAME = T_FRAME + 16
+; vinsertf128 y,y,oword ptr [rsp+T_FRAME],1
+; T_FRAME = T_FRAME + 16
+ ENDIF
+ ENDM
+ add rsp,S_FRAME
+ ENDIF
+ ELSE
+ IF S_FRAME GT 0
+ add rsp,S_FRAME
+ ENDIF
+ ENDIF
+ IF _IPP32E NE _IPP32E_N0
+ vzeroupper
+ ENDIF
+ENDM
+
+COMP_ABI MACRO x
+ IF IPP_ABI EQ 0 ;; if defined win32e
+ IF x GT 0
+ mov rdi,rcx ;; ARG_1
+ ENDIF
+ IF x GT 1
+ mov rsi,rdx ;; ARG_2
+ ENDIF
+ IF x GT 2
+ mov rdx,r8 ;; ARG_3
+ ENDIF
+ IF x GT 3
+ mov rcx,r9 ;; ARG_4
+ ENDIF
+ IF x GT 4
+ mov r8,[rsp+S_FRAME+GPR_FRAME+40] ;; ARG_5
+ ENDIF
+ IF x GT 5
+ mov r9,[rsp+S_FRAME+GPR_FRAME+48] ;; ARG_6
+ ENDIF
+ IF x GT 6
+ FIRST_P = S_FRAME+GPR_FRAME+56 ;; ARG_7
+ ARG_7 = S_FRAME+GPR_FRAME+56
+ ENDIF
+ ENDIF
+ IF IPP_ABI EQ 1 ;; if defined win32s
+ FIRST_P = S_FRAME+GPR_FRAME+8
+ IF x GT 0
+ mov [rsp+FIRST_P],rcx
+ ARG_1 = FIRST_P
+ ENDIF
+ IF x GT 1
+ mov [rsp+FIRST_P+8],rdx
+ ARG_2 = ARG_1+8
+ ENDIF
+ IF x GT 2
+ mov [rsp+FIRST_P+16],r8
+ ARG_3 = ARG_2+8
+ ENDIF
+ IF x GT 3
+ mov [rsp+FIRST_P+24],r9
+ ARG_4 = ARG_3+8
+ ENDIF
+ IF x GT 4
+ ARG_5 = ARG_4+8
+ ENDIF
+ IF x GT 5
+ ARG_6 = ARG_5+8
+ ENDIF
+ IF x GT 6
+ ARG_7 = ARG_6+8 ;; ARG_7
+ ENDIF
+ ENDIF
+ IF IPP_ABI EQ 2 ;; if defined linux32s
+ FIRST_P = INP_FRAME
+ IF x GT 0
+ mov [rsp+FIRST_P],rdi
+ ARG_1 = FIRST_P
+ ENDIF
+ IF x GT 1
+ mov [rsp+FIRST_P+8],rsi
+ ARG_2 = ARG_1+8
+ ENDIF
+ IF x GT 2
+ mov [rsp+FIRST_P+16],rdx
+ ARG_3 = ARG_2+8
+ ENDIF
+ IF x GT 3
+ mov [rsp+FIRST_P+24],rcx
+ ARG_4 = ARG_3+8
+ ENDIF
+ IF x GT 4
+ mov [rsp+FIRST_P+32],r8
+ ARG_5 = ARG_4+8
+ ENDIF
+ IF x GT 5
+ mov [rsp+FIRST_P+40],r9
+ ARG_6 = ARG_5+8
+ ENDIF
+ IF x GT 6
+ ARG_7 = S_FRAME+GPR_FRAME+8
+ ENDIF
+ ENDIF
+ IF IPP_ABI EQ 3
+ IF x GT 6 ;; ARG_1 = rdi ARG_2 = rsi ARG_3 = rdx ARG_4 = rcx ARG_5 = r8 ARG_6 = r9
+ FIRST_P = S_FRAME+GPR_FRAME+8 ;; ARG_7
+ ARG_7 = S_FRAME+GPR_FRAME+8
+ ENDIF
+ ENDIF
+ IF x GT 7
+ ARG_8 = ARG_7+8 ;; ARG_8
+ ENDIF
+ IF x GT 8
+ ARG_9 = ARG_8+8 ;; ARG_9
+ ENDIF
+ IF x GT 9
+ ARG_10 = ARG_9+8 ;; ARG_10
+ ENDIF
+ IF x GT 10
+ ARG_11 = ARG_10+8 ;; ARG_11
+ ENDIF
+ IF x GT 11
+ ARG_12 = ARG_11+8 ;; ARG_12
+ ENDIF
+ IF x GT 12
+ ARG_13 = ARG_12+8 ;; ARG_13
+ ENDIF
+ IF x GT 13
+ ARG_14 = ARG_13+8 ;; ARG_14
+ ENDIF
+ IF x GT 14
+ ARG_15 = ARG_14+8 ;; ARG_15
+ ENDIF
+ IF x GT 15
+ ARG_16 = ARG_15+8 ;; ARG_16
+ ENDIF
+ IF x GT 16
+ ARG_17 = ARG_16+8 ;; ARG_17
+ ENDIF
+ IF x GT 17
+ ARG_18 = ARG_17+8 ;; ARG_18
+ ENDIF
+; IF IPP_ABI LT 2 ;; Windows
+ .ENDPROLOG
+; ENDIF
+ENDM
+
+; MNI (TNI) SNI (SSE4.1) STTNI (SSE4.2)
+
+IF DEFINED (LINUX32E) OR DEFINED (_YASM) ; MNI macro for Linux or for Windows
+
+ sha1rnds4 MACRO op1:req, op2:req, imm8:req
+ %ECHO @CatStr(<sha1rnds4 >, < op1,>, < op2,>, < imm8 >)
+ endm
+ sha1nexte MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1nexte >, < op1,>, < op2 >)
+ endm
+ sha1msg1 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1msg1 >, < op1,>, < op2 >)
+ endm
+ sha1msg2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1msg2 >, < op1,>, < op2 >)
+ endm
+ sha256msg1 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256msg1 >, < op1,>, < op2 >)
+ endm
+ sha256msg2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256msg2 >, < op1,>, < op2 >)
+ endm
+ sha256rnds2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256rnds2 >, < op1,>, < op2 >)
+ endm
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MNI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ IFNDEF ML1200
+ adcx macro x:req, z:req
+ %ECHO @CatStr(<adcx >, < x,>, < z >)
+ endm
+ adox macro x:req, z:req
+ %ECHO @CatStr(<adox >, < x,>, < z >)
+ endm
+
+ IFNDEF ML1100
+ IFNDEF D_ML900
+
+ phaddw macro x:req, y:req
+ %ECHO @CatStr(<phaddw >, < x,>, < y >)
+ endm
+ phaddd macro x:req, y:req
+ %ECHO @CatStr(<phaddd >, < x,>, < y >)
+ endm
+ phaddsw macro x:req, y:req
+ %ECHO @CatStr(<phaddsw >, < x,>, < y >)
+ endm
+ phsubw macro x:req, y:req
+ %ECHO @CatStr(<phsubw >, < x,>, < y >)
+ endm
+ phsubd macro x:req, y:req
+ %ECHO @CatStr(<phsubd >, < x,>, < y >)
+ endm
+ phsubsw macro x:req, y:req
+ %ECHO @CatStr(<phsubsw >, < x,>, < y >)
+ endm
+ pmaddubsw macro x:req, y:req
+ %ECHO @CatStr(<pmaddubsw >, < x,>, < y >)
+ endm
+ pmulhrsw macro x:req, y:req
+ %ECHO @CatStr(<pmulhrsw >, < x,>, < y >)
+ endm
+ pshufb macro x:req, y:req
+ %ECHO @CatStr(<pshufb >, < x,>, < y >)
+ endm
+ psignb macro x:req, y:req
+ %ECHO @CatStr(<psignb >, < x,>, < y >)
+ endm
+ psignw macro x:req, y:req
+ %ECHO @CatStr(<psignw >, < x,>, < y >)
+ endm
+ psignd macro x:req, y:req
+ %ECHO @CatStr(<psignd >, < x,>, < y >)
+ endm
+ palignr macro x:req, y:req, z:req
+ %ECHO @CatStr(<palignr >, < x,>, < y,>, < z >)
+ endm
+ pabsb macro x:req, y:req
+ %ECHO @CatStr(<pabsb >, < x,>, < y >)
+ endm
+ pabsw macro x:req, y:req
+ %ECHO @CatStr(<pabsw >, < x,>, < y >)
+ endm
+ pabsd macro x:req, y:req
+ %ECHO @CatStr(<pabsd >, < x,>, < y >)
+ endm
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SNI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ blendpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<blendpd >, < x,>, < y,>, < z >)
+ endm
+ blendps macro x:req, y:req, z:req
+ %ECHO @CatStr(<blendps >, < x,>, < y,>, < z >)
+ endm
+ blendvpd macro x:req, y:req, z
+ %ECHO @CatStr(<blendvpd >, < x,>, < y>)
+ endm
+ blendvps macro x:req, y:req, z
+ %ECHO @CatStr(<blendvps >, < x,>, < y>)
+ endm
+ dppd macro x:req, y:req, z:req
+ %ECHO @CatStr(<dppd >, < x,>, < y,>, < z >)
+ endm
+ dpps macro x:req, y:req, z:req
+ %ECHO @CatStr(<dpps >, < x,>, < y,>, < z >)
+ endm
+ extractps macro x:req, y:req, z:req
+ %ECHO @CatStr(<extractps >, < x,>, < y,>, < z >)
+ endm
+ insertps macro x:req, y:req, z:req
+ %ECHO @CatStr(<insertps >, < x,>, < y,>, < z >)
+ endm
+ movntdqa macro x:req, y:req
+ %ECHO @CatStr(<movntdqa >, < x,>, < y>)
+ endm
+ mpsadbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<mpsadbw >, < x,>, < y,>, < z >)
+ endm
+ packusdw macro x:req, y:req
+ %ECHO @CatStr(<packusdw >, < x,>, < y>)
+ endm
+ pblendvb macro x:req, y:req, z
+ %ECHO @CatStr(<pblendvb >, < x,>, < y>)
+ endm
+ pblendw macro x:req, y:req, z:req
+ %ECHO @CatStr(<pblendw >, < x,>, < y,>, < z >)
+ endm
+ pcmpeqq macro x:req, y:req
+ %ECHO @CatStr(<pcmpeqq >, < x,>, < y>)
+ endm
+ pextrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrb >, < x,>, < y,>, < z >)
+ endm
+ pextrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrd >, < x,>, < y,>, < z >)
+ endm
+ pextrq macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrq >, < x,>, < y,>, < z >)
+ endm
+IF _IPP32E GE _IPP32E_Y8
+ OPTION NOKEYWORD:<pextrw>
+ pextrw macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrw >, < x,>, < y,>, < z >)
+ endm
+ENDIF
+ phminposuw macro x:req, y:req
+ %ECHO @CatStr(<phminposuw >, < x,>, < y>)
+ endm
+ pinsrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<pinsrb >, < x,>, < y,>, < z >)
+ endm
+ pinsrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<pinsrd >, < x,>, < y,>, < z >)
+ endm
+ pinsrq macro x:req, y:req, z:req
+ %ECHO @CatStr(<pinsrq >, < x,>, < y,>, < z >)
+ endm
+ pmaxsb macro x:req, y:req
+ %ECHO @CatStr(<pmaxsb >, < x,>, < y>)
+ endm
+ pmaxsd macro x:req, y:req
+ %ECHO @CatStr(<pmaxsd >, < x,>, < y>)
+ endm
+ pmaxud macro x:req, y:req
+ %ECHO @CatStr(<pmaxud >, < x,>, < y>)
+ endm
+ pmaxuw macro x:req, y:req
+ %ECHO @CatStr(<pmaxuw >, < x,>, < y>)
+ endm
+ pminsb macro x:req, y:req
+ %ECHO @CatStr(<pminsb >, < x,>, < y>)
+ endm
+ pminsd macro x:req, y:req
+ %ECHO @CatStr(<pminsd >, < x,>, < y>)
+ endm
+ pminud macro x:req, y:req
+ %ECHO @CatStr(<pminud >, < x,>, < y>)
+ endm
+ pminuw macro x:req, y:req
+ %ECHO @CatStr(<pminuw >, < x,>, < y>)
+ endm
+ pmovsxbw macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbw >, < x,>, < y>)
+ endm
+ pmovsxbd macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbd >, < x,>, < y>)
+ endm
+ pmovsxbq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbq >, < x,>, < y>)
+ endm
+ pmovsxwd macro x:req, y:req
+ %ECHO @CatStr(<pmovsxwd >, < x,>, < y>)
+ endm
+ pmovsxwq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxwq >, < x,>, < y>)
+ endm
+ pmovsxdq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxdq >, < x,>, < y>)
+ endm
+ pmovzxbw macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbw >, < x,>, < y>)
+ endm
+ pmovzxbd macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbd >, < x,>, < y>)
+ endm
+ pmovzxbq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbq >, < x,>, < y>)
+ endm
+ pmovzxwd macro x:req, y:req
+ %ECHO @CatStr(<pmovzxwd >, < x,>, < y>)
+ endm
+ pmovzxwq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxwq >, < x,>, < y>)
+ endm
+ pmovzxdq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxdq >, < x,>, < y>)
+ endm
+ pmuldq macro x:req, y:req
+ %ECHO @CatStr(<pmuldq >, < x,>, < y>)
+ endm
+ pmulld macro x:req, y:req
+ %ECHO @CatStr(<pmulld >, < x,>, < y>)
+ endm
+ ptest macro x:req, y:req
+ %ECHO @CatStr(<ptest >, < x,>, < y>)
+ endm
+ roundpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundpd >, < x,>, < y,>, < z >)
+ endm
+ roundps macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundps >, < x,>, < y,>, < z >)
+ endm
+ roundsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundsd >, < x,>, < y,>, < z >)
+ endm
+ roundss macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundss >, < x,>, < y,>, < z >)
+ endm
+; SSE4.2
+ pcmpestri macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpestri >, < x,>, < y,>, < z >)
+ endm
+ pcmpestrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpestrm >, < x,>, < y,>, < z >)
+ endm
+ pcmpistri macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpistri >, < x,>, < y,>, < z >)
+ endm
+ pcmpistrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpistrm >, < x,>, < y,>, < z >)
+ endm
+ pcmpgtq macro x:req, y:req
+ %ECHO @CatStr(<pcmpgtq >, < x,>, < y>)
+ endm
+ crc32 macro x:req, y:req
+ %ECHO @CatStr(<crc32 >, < x,>, < y>)
+ endm
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WSM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+aesenc macro x:req, y:req
+ %ECHO @CatStr(<aesenc >, < x,>, < y>)
+ endm
+aesenclast macro x:req, y:req
+ %ECHO @CatStr(<aesenclast >, < x,>, < y>)
+ endm
+aesdec macro x:req, y:req
+ %ECHO @CatStr(<aesdec >, < x,>, < y>)
+ endm
+aesdeclast macro x:req, y:req
+ %ECHO @CatStr(<aesdeclast >, < x,>, < y>)
+ endm
+aesimc macro x:req, y:req
+ %ECHO @CatStr(<aesimc >, < x,>, < y>)
+ endm
+aeskeygenassist macro x:req, y:req, z:req
+ %ECHO @CatStr(<aeskeygenassist >, < x,>, < y,>, < z >)
+ endm
+pclmulqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<pclmulqdq >, < x,>, < y,>, < z >)
+ endm
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AVX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+vaesenc macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesenc >, < x,>, < y,>, < z >)
+ endm
+vaesenclast macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesenclast >, < x,>, < y,>, < z >)
+ endm
+vaesdec macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesdec >, < x,>, < y,>, < z >)
+ endm
+vaesdeclast macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesdeclast >, < x,>, < y,>, < z >)
+ endm
+vaesimc macro x:req, y:req
+ %ECHO @CatStr(<vaesimc >, < x,>, < y>)
+ endm
+vaeskeygenassist macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaeskeygenassist >, < x,>, < y,>, < z >)
+ endm
+vaddpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddpd >, < x,>, < y,>, < z >)
+ endm
+vaddps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddps >, < x,>, < y,>, < z >)
+ endm
+vaddsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsd >, < x,>, < y,>, < z >)
+ endm
+vaddss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddss >, < x,>, < y,>, < z >)
+ endm
+vaddsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsubpd >, < x,>, < y,>, < z >)
+ endm
+vaddsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsubps >, < x,>, < y,>, < z >)
+ endm
+vandpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandpd >, < x,>, < y,>, < z >)
+ endm
+vandps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandps >, < x,>, < y,>, < z >)
+ endm
+vandnpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandnpd >, < x,>, < y,>, < z >)
+ endm
+vandnps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandnps >, < x,>, < y,>, < z >)
+ endm
+vblendpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendvpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendvpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendvps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendvps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vbroadcastss macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastss >, < x,>, < y>)
+ endm
+vbroadcastsd macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastsd >, < x,>, < y>)
+ endm
+vbroadcastf128 macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastf128 >, < x,>, < y>)
+ endm
+vcmpeqpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqpd >, < x,>, < y,>, < z >)
+ endm
+vcmpltpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltpd >, < x,>, < y,>, < z >)
+ endm
+vcmplepd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmplepd >, < x,>, < y,>, < z >)
+ endm
+vcmpunordpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordpd >, < x,>, < y,>, < z >)
+ endm
+vcmpneqpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqpd >, < x,>, < y,>, < z >)
+ endm
+vcmpnltpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltpd >, < x,>, < y,>, < z >)
+ endm
+vcmpnlepd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnlepd >, < x,>, < y,>, < z >)
+ endm
+vcmpordpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordpd >, < x,>, < y,>, < z >)
+ endm
+vcmppd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmppd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpsd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpsd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpeqps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqps >, < x,>, < y,>, < z >)
+ endm
+vcmpltps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltps >, < x,>, < y,>, < z >)
+ endm
+vcmpleps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpleps >, < x,>, < y,>, < z >)
+ endm
+vcmpunordps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordps >, < x,>, < y,>, < z >)
+ endm
+vcmpneqps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqps >, < x,>, < y,>, < z >)
+ endm
+vcmpnltps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltps >, < x,>, < y,>, < z >)
+ endm
+vcmpnleps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnleps >, < x,>, < y,>, < z >)
+ endm
+vcmpordps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordps >, < x,>, < y,>, < z >)
+ endm
+vcmpeqsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqsd >, < x,>, < y,>, < z >)
+ endm
+vcmpltsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltsd >, < x,>, < y,>, < z >)
+ endm
+vcmplesd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmplesd >, < x,>, < y,>, < z >)
+ endm
+vcmpunordsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordsd >, < x,>, < y,>, < z >)
+ endm
+vcmpneqsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqsd >, < x,>, < y,>, < z >)
+ endm
+vcmpnltsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltsd >, < x,>, < y,>, < z >)
+ endm
+vcmpnlesd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnlesd >, < x,>, < y,>, < z >)
+ endm
+vcmpordsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordsd >, < x,>, < y,>, < z >)
+ endm
+vcmpss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpeqss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqss >, < x,>, < y,>, < z >)
+ endm
+vcmpltss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltss >, < x,>, < y,>, < z >)
+ endm
+vcmpless macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpless >, < x,>, < y,>, < z >)
+ endm
+vcmpunordss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordss >, < x,>, < y,>, < z >)
+ endm
+vcmpneqss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqss >, < x,>, < y,>, < z >)
+ endm
+vcmpnltss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltss >, < x,>, < y,>, < z >)
+ endm
+vcmpnless macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnless >, < x,>, < y,>, < z >)
+ endm
+vcmpordss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordss >, < x,>, < y,>, < z >)
+ endm
+vcomisd macro x:req, y:req
+ %ECHO @CatStr(<vcomisd >, < x,>, < y>)
+ endm
+vcomiss macro x:req, y:req
+ %ECHO @CatStr(<vcomiss >, < x,>, < y>)
+ endm
+vcvtdq2pd macro x:req, y:req
+ %ECHO @CatStr(<vcvtdq2pd >, < x,>, < y>)
+ endm
+vcvtdq2ps macro x:req, y:req
+ %ECHO @CatStr(<vcvtdq2ps >, < x,>, < y>)
+ endm
+vcvtpd2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvtpd2dq >, < x,>, < y>)
+ endm
+vcvtpd2ps macro x:req, y:req
+ %ECHO @CatStr(<vcvtpd2ps >, < x,>, < y>)
+ endm
+vcvtps2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvtps2dq >, < x,>, < y>)
+ endm
+vcvtps2pd macro x:req, y:req
+ %ECHO @CatStr(<vcvtps2pd >, < x,>, < y>)
+ endm
+vcvtsd2si macro x:req, y:req
+ %ECHO @CatStr(<vcvtsd2si >, < x,>, < y>)
+ endm
+vcvtsd2ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsd2ss >, < x,>, < y,>, < z>)
+ endm
+vcvtsi2sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsi2sd >, < x,>, < y,>, < z>)
+ endm
+vcvtsi2ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsi2ss >, < x,>, < y,>, < z>)
+ endm
+vcvtss2sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtss2sd >, < x,>, < y,>, < z>)
+ endm
+vcvtss2si macro x:req, y:req
+ %ECHO @CatStr(<vcvtss2si >, < x,>, < y>)
+ endm
+vcvttpd2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvttpd2dq >, < x,>, < y>)
+ endm
+vcvttps2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvttps2dq >, < x,>, < y>)
+ endm
+vcvttsd2si macro x:req, y:req
+ %ECHO @CatStr(<vcvttsd2si >, < x,>, < y>)
+ endm
+vcvttss2si macro x:req, y:req
+ %ECHO @CatStr(<vcvttss2si >, < x,>, < y>)
+ endm
+vdivpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivpd >, < x,>, < y,>, < z >)
+ endm
+vdivps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivps >, < x,>, < y,>, < z >)
+ endm
+vdivsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivsd >, < x,>, < y,>, < z >)
+ endm
+vdivss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivss >, < x,>, < y,>, < z >)
+ endm
+vdppd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vdppd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vdpps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vdpps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vextractf128 macro x:req, y:req, z:req
+ %ECHO @CatStr(<vextractf128 >, < x,>, < y,>, < z >)
+ endm
+vextractps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vextractps >, < x,>, < y,>, < z >)
+ endm
+vhaddpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhaddpd >, < x,>, < y,>, < z >)
+ endm
+vhaddps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhaddps >, < x,>, < y,>, < z >)
+ endm
+vhsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhsubpd >, < x,>, < y,>, < z >)
+ endm
+vhsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhsubps >, < x,>, < y,>, < z >)
+ endm
+vinsertf128 macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vinsertf128 >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vinsertps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vinsertps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vlddqu macro x:req, y:req
+ %ECHO @CatStr(<vlddqu >, < x,>, < y>)
+ endm
+vldmxcsr macro x:req
+ %ECHO @CatStr(<vldmxcsr >, < x>)
+ endm
+vmaskmovdqu macro x:req, y:req
+ %ECHO @CatStr(<vmaskmovdqu >, < x,>, < y>)
+ endm
+vmaskmovpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaskmovpd >, < x,>, < y,>, < z >)
+ endm
+vmaskmovps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaskmovps >, < x,>, < y,>, < z >)
+ endm
+vmaxpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxpd >, < x,>, < y,>, < z >)
+ endm
+vmaxps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxps >, < x,>, < y,>, < z >)
+ endm
+vmaxsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxsd >, < x,>, < y,>, < z >)
+ endm
+vmaxss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxss >, < x,>, < y,>, < z >)
+ endm
+vminpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminpd >, < x,>, < y,>, < z >)
+ endm
+vminps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminps >, < x,>, < y,>, < z >)
+ endm
+vminsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminsd >, < x,>, < y,>, < z >)
+ endm
+vminss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminss >, < x,>, < y,>, < z >)
+ endm
+vmovapd macro x:req, y:req
+ %ECHO @CatStr(<vmovapd >, < x,>, < y>)
+ endm
+vmovaps macro x:req, y:req
+ %ECHO @CatStr(<vmovaps >, < x,>, < y>)
+ endm
+vmovd macro x:req, y:req
+ %ECHO @CatStr(<vmovd >, < x,>, < y>)
+ endm
+vmovddup macro x:req, y:req
+ %ECHO @CatStr(<vmovddup >, < x,>, < y>)
+ endm
+vmovdqa macro x:req, y:req
+ %ECHO @CatStr(<vmovdqa >, < x,>, < y>)
+ endm
+vmovdqu macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovdqu >, < x,>, < y>)
+ endm
+vmovhlps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovhlps >, < x,>, < y,>, < z>)
+ endm
+vmovhpd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovhpd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovhpd >, < x,>, < y>)
+ ENDIF
+endm
+vmovhps macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovhps >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovhps >, < x,>, < y>)
+ ENDIF
+endm
+vmovlhps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovlhps >, < x,>, < y,>, < z>)
+ endm
+vmovlpd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovlpd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovlpd >, < x,>, < y>)
+ ENDIF
+endm
+vmovlps macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovlps >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovlps >, < x,>, < y>)
+ ENDIF
+endm
+vmovmskpd macro x:req, y:req
+ %ECHO @CatStr(<vmovmskpd >, < x,>, < y>)
+ endm
+vmovmskps macro x:req, y:req
+ %ECHO @CatStr(<vmovmskps >, < x,>, < y>)
+ endm
+vmovntdq macro x:req, y:req
+ %ECHO @CatStr(<vmovntdq >, < x,>, < y>)
+ endm
+vmovntdqa macro x:req, y:req
+ %ECHO @CatStr(<vmovntdqa >, < x,>, < y>)
+ endm
+vmovntpd macro x:req, y:req
+ %ECHO @CatStr(<vmovntpd >, < x,>, < y>)
+ endm
+vmovntps macro x:req, y:req
+ %ECHO @CatStr(<vmovntps >, < x,>, < y>)
+ endm
+vmovntq macro x:req, y:req
+ %ECHO @CatStr(<vmovntq >, < x,>, < y>)
+ endm
+vmovq macro x:req, y:req
+ %ECHO @CatStr(<vmovq >, < x,>, < y>)
+ endm
+vmovsd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovsd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovsd >, < x,>, < y>)
+ ENDIF
+endm
+vmovshdup macro x:req, y:req
+ %ECHO @CatStr(<vmovshdup >, < x,>, < y>)
+ endm
+vmovsldup macro x:req, y:req
+ %ECHO @CatStr(<vmovsldup >, < x,>, < y>)
+ endm
+vmovss macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovss >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovss >, < x,>, < y>)
+ ENDIF
+endm
+vmovupd macro x:req, y:req
+ %ECHO @CatStr(<vmovupd >, < x,>, < y>)
+ endm
+vmovups macro x:req, y:req
+ %ECHO @CatStr(<vmovups >, < x,>, < y>)
+ endm
+vmpsadbw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vmpsadbw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vmulpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulpd >, < x,>, < y,>, < z >)
+ endm
+vmulps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulps >, < x,>, < y,>, < z >)
+ endm
+vmulsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulsd >, < x,>, < y,>, < z >)
+ endm
+vmulss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulss >, < x,>, < y,>, < z >)
+ endm
+vorpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vorpd >, < x,>, < y,>, < z >)
+ endm
+vorps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vorps >, < x,>, < y,>, < z >)
+ endm
+
+vpabsb macro x:req, y:req
+ %ECHO @CatStr(<vpabsb >, < x,>, < y>)
+ endm
+vpabsw macro x:req, y:req
+ %ECHO @CatStr(<vpabsw >, < x,>, < y>)
+ endm
+vpabsd macro x:req, y:req
+ %ECHO @CatStr(<vpabsd >, < x,>, < y>)
+ endm
+vpackssdw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackssdw >, < x,>, < y,>, < z >)
+ endm
+vpacksswb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpacksswb >, < x,>, < y,>, < z >)
+ endm
+vpackuswb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackuswb >, < x,>, < y,>, < z >)
+ endm
+vpackusdw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackusdw >, < x,>, < y,>, < z >)
+ endm
+vpaddb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddb >, < x,>, < y,>, < z >)
+ endm
+vpaddd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddd >, < x,>, < y,>, < z >)
+ endm
+vpaddq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddq >, < x,>, < y,>, < z >)
+ endm
+vpaddsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddsb >, < x,>, < y,>, < z >)
+ endm
+vpaddsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddsw >, < x,>, < y,>, < z >)
+ endm
+vpaddusb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddusb >, < x,>, < y,>, < z >)
+ endm
+vpaddusw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddusw >, < x,>, < y,>, < z >)
+ endm
+vpaddw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddw >, < x,>, < y,>, < z >)
+ endm
+vpand macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpand >, < x,>, < y,>, < z >)
+ endm
+vpandn macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpandn >, < x,>, < y,>, < z >)
+ endm
+vpavgb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpavgb >, < x,>, < y,>, < z >)
+ endm
+vpavgw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpavgw >, < x,>, < y,>, < z >)
+ endm
+vpalignr macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpalignr >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpblendvb macro x:req, y:req, z:req, q:req
+ %ECHO @CatStr(<vpblendvb >, < x,>, < y,>, < z,>, < q>)
+ endm
+vpblendw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpblendw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpclmulqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpclmulqdq >, < x,>, < y,>, < z >)
+ endm
+vpcmpestri macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpestri >, < x,>, < y,>, < z >)
+ endm
+vpcmpestrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpestrm >, < x,>, < y,>, < z >)
+ endm
+vpcmpistri macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpistri >, < x,>, < y,>, < z >)
+ endm
+vpcmpistrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpistrm >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqb >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqd >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqw >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqq >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtb >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtd >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtw >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtq >, < x,>, < y,>, < z >)
+ endm
+vpermilpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermilpd >, < x,>, < y,>, < z >)
+ endm
+vpermil2pd macro x:req, y:req, z:req, v:req, imm:req
+ %ECHO @CatStr(<vpermil2pd >, < x,>, < y,>, < z,>, < v,>, < imm>)
+ endm
+vpermilps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermilps >, < x,>, < y,>, < z >)
+ endm
+vpermil2ps macro x:req, y:req, z:req, v:req, imm:req
+ %ECHO @CatStr(<vpermil2ps >, < x,>, < y,>, < z,>, < v,>, < imm>)
+ endm
+vperm2f128 macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vperm2f128 >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpextrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrb >, < x,>, < y,>, < z >)
+ endm
+vpextrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrd >, < x,>, < y,>, < z >)
+ endm
+vpextrq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrq >, < x,>, < y,>, < z >)
+ endm
+vpextrw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrw >, < x,>, < y,>, < z >)
+ endm
+vphaddw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddw >, < x,>, < y,>, < z >)
+ endm
+vphaddd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddd >, < x,>, < y,>, < z >)
+ endm
+vphaddsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddsw >, < x,>, < y,>, < z >)
+ endm
+vphminposuw macro x:req, y:req
+ %ECHO @CatStr(<vphminposuw >, < x,>, < y>)
+ endm
+vphsubw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubw >, < x,>, < y,>, < z >)
+ endm
+vphsubd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubd >, < x,>, < y,>, < z >)
+ endm
+vphsubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubsw >, < x,>, < y,>, < z >)
+ endm
+vpinsrb macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrb >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrq macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrq >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpmaddwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaddwd >, < x,>, < y,>, < z >)
+ endm
+vpmaddubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaddubsw >, < x,>, < y,>, < z >)
+ endm
+vpmaxsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsb >, < x,>, < y,>, < z >)
+ endm
+vpmaxsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsd >, < x,>, < y,>, < z >)
+ endm
+vpmaxsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsw >, < x,>, < y,>, < z >)
+ endm
+vpmaxub macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxub >, < x,>, < y,>, < z >)
+ endm
+vpmaxud macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxud >, < x,>, < y,>, < z >)
+ endm
+vpmaxuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxuw >, < x,>, < y,>, < z >)
+ endm
+vpminsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsb >, < x,>, < y,>, < z >)
+ endm
+vpminsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsd >, < x,>, < y,>, < z >)
+ endm
+vpminsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsw >, < x,>, < y,>, < z >)
+ endm
+vpminub macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminub >, < x,>, < y,>, < z >)
+ endm
+vpminud macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminud >, < x,>, < y,>, < z >)
+ endm
+vpminuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminuw >, < x,>, < y,>, < z >)
+ endm
+vpmovmskb macro x:req, y:req
+ %ECHO @CatStr(<vpmovmskb >, < x,>, < y>)
+ endm
+vpmovsxbw macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbw >, < x,>, < y>)
+ endm
+vpmovsxbd macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbd >, < x,>, < y>)
+ endm
+vpmovsxbq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbq >, < x,>, < y>)
+ endm
+vpmovsxwd macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxwd >, < x,>, < y>)
+ endm
+vpmovsxwq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxwq >, < x,>, < y>)
+ endm
+vpmovsxdq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxdq >, < x,>, < y>)
+ endm
+vpmovzxbw macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbw >, < x,>, < y>)
+ endm
+vpmovzxbd macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbd >, < x,>, < y>)
+ endm
+vpmovzxbq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbq >, < x,>, < y>)
+ endm
+vpmovzxwd macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxwd >, < x,>, < y>)
+ endm
+vpmovzxwq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxwq >, < x,>, < y>)
+ endm
+vpmovzxdq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxdq >, < x,>, < y>)
+ endm
+vpmulhuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhuw >, < x,>, < y,>, < z >)
+ endm
+vpmulhrsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhrsw >, < x,>, < y,>, < z >)
+ endm
+vpmulhw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhw >, < x,>, < y,>, < z >)
+ endm
+vpmullw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmullw >, < x,>, < y,>, < z >)
+ endm
+vpmulld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulld >, < x,>, < y,>, < z >)
+ endm
+vpmuludq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmuludq >, < x,>, < y,>, < z >)
+ endm
+vpmuldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmuldq >, < x,>, < y,>, < z >)
+ endm
+vpor macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpor >, < x,>, < y,>, < z >)
+ endm
+vpsadbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsadbw >, < x,>, < y,>, < z >)
+ endm
+vpshufb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufb >, < x,>, < y,>, < z >)
+ endm
+vpshufd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufd >, < x,>, < y,>, < z >)
+ endm
+vpshufhw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufhw >, < x,>, < y,>, < z >)
+ endm
+vpshuflw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshuflw >, < x,>, < y,>, < z >)
+ endm
+vpsignb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignb >, < x,>, < y,>, < z >)
+ endm
+vpsignw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignw >, < x,>, < y,>, < z >)
+ endm
+vpsignd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignd >, < x,>, < y,>, < z >)
+ endm
+vpslld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpslld >, < x,>, < y,>, < z >)
+ endm
+vpslldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpslldq >, < x,>, < y,>, < z >)
+ endm
+vpsllq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllq >, < x,>, < y,>, < z >)
+ endm
+vpsllw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllw >, < x,>, < y,>, < z >)
+ endm
+vpsrad macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrad >, < x,>, < y,>, < z >)
+ endm
+vpsraw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsraw >, < x,>, < y,>, < z >)
+ endm
+vpsrld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrld >, < x,>, < y,>, < z >)
+ endm
+vpsrldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrldq >, < x,>, < y,>, < z >)
+ endm
+vpsrlq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlq >, < x,>, < y,>, < z >)
+ endm
+vpsrlw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlw >, < x,>, < y,>, < z >)
+ endm
+vptest macro x:req, y:req
+ %ECHO @CatStr(<vptest >, < x,>, < y>)
+ endm
+vpsubb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubb >, < x,>, < y,>, < z >)
+ endm
+vpsubd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubd >, < x,>, < y,>, < z >)
+ endm
+vpsubq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubq >, < x,>, < y,>, < z >)
+ endm
+vpsubsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubsb >, < x,>, < y,>, < z >)
+ endm
+vpsubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubsw >, < x,>, < y,>, < z >)
+ endm
+vpsubusb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubusb >, < x,>, < y,>, < z >)
+ endm
+vpsubusw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubusw >, < x,>, < y,>, < z >)
+ endm
+vpsubw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubw >, < x,>, < y,>, < z >)
+ endm
+vpunpckhbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhbw >, < x,>, < y,>, < z >)
+ endm
+vpunpckhdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhdq >, < x,>, < y,>, < z >)
+ endm
+vpunpckhqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhqdq >, < x,>, < y,>, < z >)
+ endm
+vpunpckhwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhwd >, < x,>, < y,>, < z >)
+ endm
+vpunpcklbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklbw >, < x,>, < y,>, < z >)
+ endm
+vpunpckldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckldq >, < x,>, < y,>, < z >)
+ endm
+vpunpcklqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklqdq >, < x,>, < y,>, < z >)
+ endm
+vpunpcklwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklwd >, < x,>, < y,>, < z >)
+ endm
+vrcpps macro x:req, y:req
+ %ECHO @CatStr(<vrcpps >, < x,>, < y>)
+ endm
+vrcpss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vrcpss >, < x,>, < y>)
+ endm
+vrsqrtps macro x:req, y:req
+ %ECHO @CatStr(<vrsqrtps >, < x,>, < y>)
+ endm
+vrsqrtss macro x:req, y:req
+ %ECHO @CatStr(<vrsqrtss >, < x,>, < y>)
+ endm
+vroundpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vroundpd >, < x,>, < y,>, < z >)
+ endm
+vroundps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vroundps >, < x,>, < y,>, < z >)
+ endm
+vroundsd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vroundsd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vroundss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vroundss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vshufpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vshufpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vshufps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vshufps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vsqrtpd macro x:req, y:req
+ %ECHO @CatStr(<vsqrtpd >, < x,>, < y>)
+ endm
+vsqrtps macro x:req, y:req
+ %ECHO @CatStr(<vsqrtps >, < x,>, < y>)
+ endm
+vsqrtsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsqrtsd >, < x,>, < y,>, < z >)
+ endm
+vsqrtss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsqrtss >, < x,>, < y,>, < z >)
+ endm
+vstmxcsr macro x:req
+ %ECHO @CatStr(<vstmxcsr >, < x>)
+ endm
+vsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubpd >, < x,>, < y,>, < z >)
+ endm
+vsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubps >, < x,>, < y,>, < z >)
+ endm
+vsubsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubsd >, < x,>, < y,>, < z >)
+ endm
+vsubss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubss >, < x,>, < y,>, < z >)
+ endm
+vucomisd macro x:req, y:req
+ %ECHO @CatStr(<vucomisd >, < x,>, < y>)
+ endm
+vucomiss macro x:req, y:req
+ %ECHO @CatStr(<vucomiss >, < x,>, < y>)
+ endm
+vunpckhpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpckhpd >, < x,>, < y,>, < z >)
+ endm
+vunpckhps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpckhps >, < x,>, < y,>, < z >)
+ endm
+vunpcklpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpcklpd >, < x,>, < y,>, < z >)
+ endm
+vunpcklps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpcklps >, < x,>, < y,>, < z >)
+ endm
+vxorpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vxorpd >, < x,>, < y,>, < z >)
+ endm
+vxorps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vxorps >, < x,>, < y,>, < z >)
+ endm
+vzeroall macro
+ %ECHO @CatStr(<vzeroall>)
+ endm
+vzeroupper macro
+ %ECHO @CatStr(<vzeroupper>)
+ endm
+ ELSE
+ OPTION NOKEYWORD:<blendvpd>
+ blendvpd macro x:req, y:req, z
+ %ECHO @CatStr(<blendvpd >, < x,>, < y>)
+ endm
+ OPTION NOKEYWORD:<blendvps>
+ blendvps macro x:req, y:req, z
+ %ECHO @CatStr(<blendvps >, < x,>, < y>)
+ endm
+ OPTION NOKEYWORD:<pblendvb>
+ pblendvb macro x:req, y:req, z
+ %ECHO @CatStr(<pblendvb >, < x,>, < y>)
+ endm
+
+;; OPTION NOKEYWORD:<vpbroadcastq>
+ vpbroadcastq macro x:req, y:req
+ %ECHO @CatStr(<vpbroadcastq >, <x, >, <y >)
+ endm
+ OPTION NOKEYWORD:<vpaddq>
+ vpaddq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddq >, < x,>, < y,>, < z >)
+ endm
+ OPTION NOKEYWORD:<vpmuludq>
+ vpmuludq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmuludq >, < x,>, < y,>, < z >)
+ endm
+
+ OPTION NOKEYWORD:<vpxor>
+ vpxor macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpxor >, < x,>, < y,>, < z >)
+ endm
+
+ENDIF ;IFNDEF D_ML900
+
+
+vfmadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfmadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfmadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231pd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231pd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfmadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfmadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231ps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231ps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132sd >, < x,>, < y,>, < z >)
+ endm
+vfmadd213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213sd >, < x,>, < y,>, < z >)
+ endm
+vfmadd231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231sd >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231sd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231sd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132ss >, < x,>, < y,>, < z >)
+ endm
+vfmadd213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213ss >, < x,>, < y,>, < z >)
+ endm
+vfmadd231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231ss >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231ss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231ss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmaddsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132ss >, < x,>, < y,>, < z >)
+ endm
+vfmsub213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213ss >, < x,>, < y,>, < z >)
+ endm
+vfmsub231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231ss >, < x,>, < y,>, < z >)
+ endm
+
+; AVX2 (HSW)
+
+vpsllvd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllvd >, < x,>, < y,>, < z >)
+ endm
+vpsllvq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllvq >, < x,>, < y,>, < z >)
+ endm
+vcvtph2ps macro x:req, z:req
+ %ECHO @CatStr(<vcvtph2ps >, < x,>, < z >)
+ endm
+andn macro x:req, y:req, z:req
+ %ECHO @CatStr(<andn >, < x,>, < y,>, < z >)
+ endm
+bextr macro x:req, y:req, z:req
+ %ECHO @CatStr(<bextr >, < x,>, < y,>, < z >)
+ endm
+blsi macro x:req, z:req
+ %ECHO @CatStr(<blsi >, < x,>, < z >)
+ endm
+blsmsk macro x:req, z:req
+ %ECHO @CatStr(<blmsk >, < x,>, < z >)
+ endm
+blsr macro x:req, z:req
+ %ECHO @CatStr(<blsr >, < x,>, < z >)
+ endm
+bzhi macro x:req, y:req, z:req
+ %ECHO @CatStr(<bzhi >, < x,>, < y,>, < z >)
+ endm
+;lzcnt macro x:req, z:req
+; %ECHO @CatStr(<lzcnt >, < x,>, < z >)
+; endm
+mulx macro x:req, y:req, z:req
+ %ECHO @CatStr(<mulx >, < x,>, < y,>, < z >)
+ endm
+pdep macro x:req, y:req, z:req
+ %ECHO @CatStr(<pdep >, < x,>, < y,>, < z >)
+ endm
+pext macro x:req, y:req, z:req
+ %ECHO @CatStr(<pext >, < x,>, < y,>, < z >)
+ endm
+rorx macro x:req, y:req, z:req
+ %ECHO @CatStr(<rorx >, < x,>, < y,>, < z >)
+ endm
+sarx macro x:req, y:req, z:req
+ %ECHO @CatStr(<sarx >, < x,>, < y,>, < z >)
+ endm
+shlx macro x:req, y:req, z:req
+ %ECHO @CatStr(<shlx >, < x,>, < y,>, < z >)
+ endm
+shrx macro x:req, y:req, z:req
+ %ECHO @CatStr(<shrx >, < x,>, < y,>, < z >)
+ endm
+tzcnt macro x:req, z:req
+ %ECHO @CatStr(<tzcnt >, < x,>, < z >)
+ endm
+invpcid macro x:req, z:req
+ %ECHO @CatStr(<invpcid >, < x,>, < z >)
+ endm
+rdrand macro x:req
+ %ECHO @CatStr(<rdrand >, < x >)
+ endm
+rdseed macro x:req
+ %ECHO @CatStr(<rdseed >, < x >)
+ endm
+adcx macro x:req, z:req
+ %ECHO @CatStr(<adcx >, < x,>, < z >)
+ endm
+adox macro x:req, z:req
+ %ECHO @CatStr(<adox >, < x,>, < z >)
+ endm
+;prefetchw macro x:req
+; %ECHO @CatStr(<prefetchw >, < x >)
+; endm
+vpbroadcast macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpbroadcast >, < x,>, < y,>, < z >)
+ endm
+vpbroadcastb macro x:req, y:req
+ %ECHO @CatStr(<vpbroadcastb >, <x, >, <y >)
+endm
+vpbroadcastw macro x:req, y:req
+ %ECHO @CatStr(<vpbroadcastw >, <x, >, <y >)
+endm
+vpbroadcastd macro x:req, y:req
+ %ECHO @CatStr(<vpbroadcastd >, <x, >, <y >)
+endm
+vpermd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermd >, < x,>, < y,>, < z >)
+ endm
+vpermpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermpd >, < x,>, < y,>, < z >)
+ endm
+vpermps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermps >, < x,>, < y,>, < z >)
+ endm
+vpermq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermq >, < x,>, < y,>, < z >)
+ endm
+vperm2i128 macro x:req, y:req, z:req
+ %ECHO @CatStr(<vperm2i128 >, < x,>, < y,>, < z >)
+ endm
+vextracti128 macro x:req, y:req, z:req
+ %ECHO @CatStr(<vextracti128 >, < x,>, < y,>, < z >)
+ endm
+vinserti128 macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vinserti128 >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpmaskmov macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaskmov >, < x,>, < y,>, < z >)
+ endm
+vpsravd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsravd >, < x,>, < y,>, < z >)
+ endm
+vpsrlvd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlvd >, < x,>, < y,>, < z >)
+ endm
+vpsrlvq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlvq >, < x,>, < y,>, < z >)
+ endm
+vgatherdpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherdpd >, < x,>, < y,>, < z >)
+ endm
+vgatherqpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherqpd >, < x,>, < y,>, < z >)
+ endm
+vgatherdps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherdps >, < x,>, < y,>, < z >)
+ endm
+vgatherqps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherqps >, < x,>, < y,>, < z >)
+ endm
+vgatherdd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherdd >, < x,>, < y,>, < z >)
+ endm
+vgatherqd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherqd >, < x,>, < y,>, < z >)
+ endm
+vgatherdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherdq >, < x,>, < y,>, < z >)
+ endm
+vgatherqq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vgatherqq >, < x,>, < y,>, < z >)
+ endm
+;vpmaddubsw macro x:req, y:req, z:req
+; %ECHO @CatStr(<vpmaddubsw >, < x,>, < y,>, < z >)
+; endm
+;vmpsadbw macro x:req, y:req, z:req
+; %ECHO @CatStr(<vmpsadbw >, < x,>, < y,>, < z >)
+; endm
+
+ENDIF ; IFNDEF ML1100
+ENDIF ; IFNDEF ML1200
+
+ELSE ; MNI & SNI macro for Linux or for Windows
+
+IFNDEF ML1100
+
+ IF IPP_ABI LE 1
+ OPTION NOKEYWORD:<pmuludq>
+ IFHIGH_REG MACRO x, f
+ f = 0
+ FOR y,<xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15>
+ IFIDN <y>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF f EQ 0
+ FOR y,<r8,R8,r9,R9,r10,R10,r11,R11,r12,R12,r13,R13,r14,R14,r15,R15>
+ IF @InStr( , x, y ) NE 0
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ ENDM
+ IFMMX_REG MACRO x, f
+ f = 0
+ FOR y,<mm0,MM0,mm1,MM1,mm2,MM2,mm3,MM3,mm4,MM4,mm5,MM5,mm6,MM6,mm7,MM7>
+ IFIDN <y>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDM
+
+ ;;66/REX 0F F4 /r pmuludq xmm1, xmm2/m128
+ pmuludq macro dst:req, src:req
+ local x, y
+ IFMMX_REG <dst>,f
+ IF f GT 0
+ x:
+ paddq dst, src
+ y:
+ org x+1
+ db 0F4h
+ org y
+ ELSE
+ x:
+ addpd dst, src
+ y:
+ IFHIGH_REG <dst>,f
+ IF f EQ 0
+ IFHIGH_REG <src>,f
+ ENDIF
+ IF f GT 0
+ org x+3
+ ELSE
+ org x+2
+ ENDIF
+ db 0F4h
+ org y
+ ENDIF
+ endm
+
+ ENDIF
+
+nis_mni = 38h ;new instruction set
+nis_mnia = 3Ah ;new instruction set 'a'
+reg_mmx = 0Fh ;media registers type
+reg_xmm = 66h ;media registers type
+
+opc_phaddw = 01h
+opc_phaddd = 02h
+opc_phaddsw = 03h
+opc_phsubw = 05h
+opc_phsubd = 06h
+opc_phsubsw = 07h
+opc_pmaddubsw = 04h
+opc_pmulhrsw = 0Bh
+opc_pshufb = 00h
+opc_psignb = 08h
+opc_psignw = 09h
+opc_psignd = 0Ah
+opc_palignr = 0Fh
+opc_pabsb = 1Ch
+opc_pabsw = 1Dh
+opc_pabsd = 1Eh
+
+HIGHQ_GPR textequ <!<r8,R8,r9,R9,r10,R10,r11,R11,r12,R12,r13,R13,r14,R14,r15,R15!>>
+LOWQ_GPR textequ <!<rax,RAX,rcx,RCX,rdx,RDX,rbx,RBX,rsp,RSP,rbp,RBP,rsi,RSI,rdi,RDI!>>
+HIGH_XMM textequ <!<xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15!>>
+LOW_XMM textequ <!<xmm0,XMM0,xmm1,XMM1,xmm2,XMM2,xmm3,XMM3,xmm4,XMM4,xmm5,XMM5,xmm6,XMM6,xmm7,XMM7!>>
+ALL_MMX textequ <!<mm0,MM0,mm1,MM1,mm2,MM2,mm3,MM3,mm4,MM4,mm5,MM5,mm6,MM6,mm7,MM7!>>
+HIGHDQ_GPR textequ <!<R8D,r8d,R8,r8,R9D,r9d,R9,r9,R10D,r10d,R10,r10,R11D,r11d,R11,r11,R12D,r12d,R12,r12,R13D,r13d,R13,r13,R14D,r14d,R14,r14,R15D,r15d,R15,r15!>>
+LOWDQ_GPR textequ <!<EAX,eax,RAX,rax,ECX,ecx,RCX,rcx,EDX,edx,RDX,rdx,EBX,ebx,RBX,rbx,ESP,esp,RSP,rsp,EBP,ebp,RBP,rbp,ESI,esi,RSI,rsi,EDI,edi,RDI,rdi!>>
+LOWD_GPR textequ <!<eax,EAX,ecx,ECX,edx,EDX,ebx,EBX,esp,ESP,ebp,EBP,esi,ESI,edi,EDI!>>
+HIGHD_GPR textequ <!<r8d,R8D,r9d,R9D,r10d,R10D,r11d,R11D,r12d,R12D,r13d,R13D,r14d,R14D,r15d,R15D!>>
+LOWW_GPR textequ <!<ax,AX,cx,CX,dx,DX,bx,BX,sp,SP,bp,BP,si,SI,di,DI!>>
+HIGHW_GPR textequ <!<r8w,R8W,r9w,R9W,r10w,R10W,r11w,R11W,r12w,R12W,r13w,R13W,r14w,R14W,r15w,R15W!>>
+LOWB_GPR textequ <!<al,AL,cl,CL,dl,DL,bl,BL,ah,AH,ch,CH,dh,DH,bh,BH!>>
+HIGHB_GPR textequ <!<r8b,R8B,r9b,R9B,r10b,R10B,r11b,R11B,r12b,R12B,r13b,R13B,r14b,R14B,r15b,R15B,spl,SPL,bpl,BPL,sil,SIL,dil,DIL!>>
+ALL_NUM textequ <!<15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0!>>
+
+IS_REX MACRO x, REX
+ REX = 0
+ %FOR yrex,HIGH_XMM ; if xmm from 8-15 range - REX byte is required
+ IFIDN <yrex>,<x>
+ REX = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF REX EQ 0
+ %FOR yrex,HIGHDQ_GPR ; if gpr from 8-15 range - REX byte is required
+ IF @InStr( , x, yrex ) NE 0
+ REX = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ENDM
+
+IS_MMX MACRO x, MMX
+ MMX = 0
+ %FOR ymmx,ALL_MMX ; test if operand is a mmx register
+ IFIDN <ymmx>,<x>
+ MMX = 1
+ EXITM
+ ENDIF
+ ENDM
+ENDM
+
+SUBST_GPR MACRO x ; this macro substites any gpr from the high half (8-15)
+ xretgpr textequ <x> ; with the gpr from the low half wich produces the same
+ qgpr = 0 ; index in the mod/r/m and sib bytes
+ %FOR ygpr,HIGHDQ_GPR
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ fgpr = 0
+ %FOR zgpr,LOWDQ_GPR
+ IF fgpr EQ qgpr
+ f1gpr SUBSTR <x>, 1, posgpr-1
+ f2gpr SUBSTR <x>, posgpr + @SizeStr( ygpr )
+ xretgpr CATSTR <f1gpr>, < zgpr >, <f2gpr>
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ EXITM xretgpr
+ENDM
+
+SUBST_XMM MACRO x ; this macro substites any xmm from the high half (8-15)
+ xretxmm textequ <x> ; with the xmm from the low half wich produces the same
+ lxmm = 0 ; index in the mod/r/m byte
+ %FOR yxmm,HIGH_XMM
+ posxmm INSTR <x>,<yxmm>
+ IF posxmm GT 0
+ fxmm = 0
+ %FOR zxmm,LOW_XMM
+ IF fxmm EQ lxmm
+ xretxmm textequ <zxmm>
+ EXITM xretxmm
+ ENDIF ; if f == l
+ fxmm = fxmm + 1
+ ENDM ; for z
+ ENDIF ; if posx > 0
+ lxmm = lxmm + 1
+ ENDM ; for y
+ EXITM xretxmm
+ENDM
+
+SUBST_HIGH MACRO x ; a wrapper for macros that substitute up-half registers
+ xs textequ SUBST_GPR( x ) ; with their ia32 analogues that have the same index in
+ xs1 textequ SUBST_GPR( %xs ) ; the mod/r/m byte
+ xs2 textequ SUBST_XMM( %xs1 )
+ EXITM xs2
+ENDM
+
+SUBST_MIMM MACRO x, y ; if "x" contains direct reference to memory operand (by
+ zimm = ( OPATTR( x )) AND 0011110111y ; name defined in code or data section) it is substituted
+ IF zimm EQ 0 ; by "y" operand in order to produce right REX byte, but
+ ximm textequ <y> ; don't produce relocation record (because current address
+ ELSE ; for relocation due to different instruction length is wrong)
+ ximm textequ <x>
+ ENDIF
+ EXITM ximm
+ENDM
+
+IS_NAME MACRO x ; if "x" contains direct reference to memory operand (by
+ znam = ( OPATTR( x )) AND 0011110111y ; name defined in code or data section) 1 is returned
+ IF znam EQ 0 ; else 0
+ xnam = 1
+ ELSE
+ xnam = 0
+ ENDIF
+ EXITM %xnam
+ENDM
+
+
+mni_instruction macro dst:req, src:req, nis:req, opc:req, imm8
+ local x0, x1, x2, x3, x4, x5, x6, x7
+
+ IS_REX <src>,REX ; do we need REX byte due to src operand?
+ REXS = REX
+ IF REXS EQ 1 ; if yes - we have to prepare substitution in order
+ s1rc textequ SUBST_HIGH( src ) ; to work correctly with direct memory operands
+ ELSE
+ s1rc textequ <src> ; else substitution is not required
+ ENDIF
+ IS_REX <dst>,REX ; do we need REX byte due to dst operand?
+ REXD = REX
+ IF REXD EQ 1 ; if yes - we have to prepare substitution in order
+ d1st textequ SUBST_HIGH( dst ) ; to work correctly with direct memory operands
+ ELSE
+ d1st textequ <dst> ; else substitution is not required
+ ENDIF
+ REX = REXS + REXD
+ NAMS = IS_NAME( src )
+ NAMD = IS_NAME( dst )
+ isname = NAMS + NAMD
+ IS_MMX <dst>,MMX ; the same instruction set for both MMX and SSE
+ IF MMX GT 0 ; we need to separate them because of different length (in bytes)
+ s2rc textequ SUBST_MIMM( src, mm0 )
+ d2st textequ SUBST_MIMM( dst, mm0 )
+ IF isname GT 0 ; if src or dst contains direct reference to memory operand
+ IF REX GT 0
+ x0:
+ nop
+ nop
+ pand d1st,s1rc ; 90 90 0F DB /r m32
+ x1:
+ org x0
+ pand d2st,s2rc ; REX 0F DB /r /r m32
+ org x0+2
+ db nis
+ db opc
+ IFNB <imm8>
+ org x0+5
+ dd 0FFFFFFFFH
+ org x1 ; 66 REX 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x1
+ ENDIF
+ ELSE
+ db reg_mmx ; MMX processing
+ x2:
+ pand dst, src ; 0F 0F DB /r m32
+ x3:
+ org x2
+ db nis
+ db opc
+ IFNB <imm8>
+ org x2+3
+ dd 0FFFFFFFFH
+ org x3 ; 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x3
+ ENDIF
+ ENDIF
+ ELSE ; if src or dst doesn't contain direct reference to memory operand
+ IF REX GT 0
+ x0:
+ pand dst,src ; REX 0F DB /r
+ org x0+1
+ pand dst,src ; REX REX 0F DB /r
+ x1:
+ org x0+1
+ db reg_mmx
+ db nis
+ db opc
+ org x1 ; REX reg_mmx nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ELSE
+ db reg_mmx ; MMX processing
+ x2:
+ pand dst, src ; reg_mmx 0F DB /r
+ x3:
+ org x2
+ db nis
+ db opc
+ org x3 ; reg_mmx nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ENDIF
+ ENDIF
+ ELSE ; SSE processing
+ s2rc textequ SUBST_MIMM( src, xmm0 )
+ d2st textequ SUBST_MIMM( dst, xmm0 )
+ IF isname GT 0 ; if src or dst contains direct reference to memory operand
+ IF REX GT 0
+ db reg_xmm
+ x4:
+ nop
+ nop
+ mulps d1st,s1rc ; 66 90 90 0F 59 /r m32
+ x5:
+ org x4
+ mulps d2st,s2rc ; 66 REX 0F 59 /r /r m32
+ org x4+2
+ db nis
+ db opc
+ IFNB <imm8>
+ org x4+5
+ dd 0FFFFFFFFH
+ org x5 ; 66 REX 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x5
+ ENDIF
+ ELSE
+ db reg_xmm
+ x6:
+ nop
+ mulps dst, src ; 66 90 0F 59 /r m32
+ x7:
+ org x6
+ db reg_mmx
+ db nis
+ db opc
+ IFNB <imm8>
+ org x6+4
+ dd 0FFFFFFFFH
+ org x7 ; 66 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x7
+ ENDIF
+ ENDIF
+ ELSE ; if src or dst doesn't contain direct reference to memory operand
+ IF REX GT 0
+ db reg_xmm
+ x4:
+ mulps dst,src ; 66 REX 0F 59 /r
+ org x4+1
+ mulps dst,src ; 66 REX REX 0F 59 /r
+ x5:
+ org x4+1
+ db reg_mmx
+ db nis
+ db opc
+ org x5 ; 66 REX 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ELSE
+ db reg_xmm
+ x6:
+ nop
+ mulps dst, src ; 66 90 0F 59 /r
+ x7:
+ org x6
+ db reg_mmx
+ db nis
+ db opc
+ org x7 ; 66 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ENDIF
+ ENDIF
+ ENDIF
+endm
+
+;IF @Version LT 900
+IFNDEF D_ML900
+
+; OPTION NOKEYWORD:<phaddw>
+; 0F 38 01 /r phaddw mm1, mm2/m64
+; 66 0F 38 01 /r phaddw xmm1, xmm2/m128
+phaddw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phaddw
+endm
+
+; OPTION NOKEYWORD:<phaddd>
+; 0F 38 02 /r phaddd mm1, mm2/m64
+; 66 0F 38 02 /r phaddd xmm1, xmm2/m128
+phaddd macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phaddd
+endm
+
+; OPTION NOKEYWORD:<phaddsw>
+; 0F 38 03 /r phaddsw mm1, mm2/m64
+; 66 0F 38 03 /r phaddsw xmm1, xmm2/m128
+phaddsw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phaddsw
+endm
+
+; OPTION NOKEYWORD:<phsubw>
+; 0F 38 05 /r phsubw mm1, mm2/m64
+; 66 0F 38 05 /r phsubw xmm1, xmm2/m128
+phsubw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phsubw
+endm
+
+; OPTION NOKEYWORD:<phsubd>
+; 0F 38 06 /r phsubd mm1, mm2/m64
+; 66 0F 38 06 /r phsubd xmm1, xmm2/m128
+phsubd macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phsubd
+endm
+
+; OPTION NOKEYWORD:<phsubsw>
+; 0F 38 07 /r phsubsw mm1, mm2/m64
+; 66 0F 38 07 /r phsubsw xmm1, xmm2/m128
+phsubsw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_phsubsw
+endm
+
+; OPTION NOKEYWORD:<pmaddubsw>
+; 0F 38 04 /r pmaddubsw mm1, mm2/m64
+; 66 0F 38 04 /r pmaddubsw xmm1, xmm2/m128
+pmaddubsw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pmaddubsw
+endm
+
+; OPTION NOKEYWORD:<pmulhrsw>
+; 0F 38 0B /r pmulhrsw mm1, mm2/m64
+; 66 0F 38 0B /r pmulhrsw xmm1, xmm2/m128
+pmulhrsw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pmulhrsw
+endm
+
+; OPTION NOKEYWORD:<pshufb>
+; 0F 38 00 /r pshufb mm1, mm2/m64
+; 66 0F 38 00 /r pshufb xmm1, xmm2/m128
+pshufb macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pshufb
+endm
+
+; OPTION NOKEYWORD:<psignb>
+; 0F 38 08 /r psignb mm1, mm2/m64
+; 66 0F 38 08 /r psignb xmm1, xmm2/m128
+psignb macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_psignb
+endm
+
+; OPTION NOKEYWORD:<psignw>
+; 0F 38 09 /r psignw mm1, mm2/m64
+; 66 0F 38 09 /r psignw xmm1, xmm2/m128
+psignw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_psignw
+endm
+
+; OPTION NOKEYWORD:<psignd>
+; 0F 38 0A /r psignd mm1, mm2/m64
+; 66 0F 38 0A /r psignd xmm1, xmm2/m128
+psignd macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_psignd
+endm
+
+; OPTION NOKEYWORD:<palignr>
+; 0F 3A 0F /r palignr mm1, mm2/m64
+; 66 0F 3A 0F /r palignr xmm1, xmm2/m128
+palignr macro dst:req, src:req, imm8:req
+ %mni_instruction dst, src, nis_mnia, opc_palignr, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pabsb>
+; 0F 38 1C /r pabsb mm1, mm2/m64
+; 66 0F 38 1C /r pabsb xmm1, xmm2/m128
+pabsb macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pabsb
+endm
+
+; OPTION NOKEYWORD:<pabsw>
+; 0F 38 1D /r pabsw mm1, mm2/m64
+; 66 0F 38 1D /r pabsw xmm1, xmm2/m128
+pabsw macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pabsw
+endm
+
+; OPTION NOKEYWORD:<pabsd>
+; 0F 38 1E /r pabsd mm1, mm2/m64
+; 66 0F 38 1E /r pabsd xmm1, xmm2/m128
+pabsd macro dst:req, src:req
+ %mni_instruction dst, src, nis_mni, opc_pabsd
+endm
+
+ENDIF
+; The End of @Version < 900
+
+; SNI (Swing new instructions or SSE4.1)
+
+nis_sni = 38h ; new instruction set
+nis_snia = 3Ah ; new instruction set 'a' (with imm8)
+
+opc_blendpd = 0Dh
+opc_blendps = 0Ch
+opc_blendvpd = 15h
+opc_blendvps = 14h
+opc_dppd = 41h
+opc_dpps = 40h
+opc_extractps = 17h
+opc_insertps = 21h
+opc_movntdqa = 2Ah
+opc_mpsadbw = 42h
+opc_pblendvb = 10h
+opc_pblendw = 0Eh
+opc_pcmpeqq = 29h
+opc_pextrb = 14h
+opc_pextrd = 16h
+opc_pextrw = 15h
+opc_phminposuw = 41h
+opc_packusdw = 2Bh
+opc_pinsrb = 20h
+opc_pinsrd = 22h
+opc_pmaxsb = 3Ch
+opc_pmaxsd = 3Dh
+opc_pmaxud = 3Fh
+opc_pmaxuw = 3Eh
+opc_pminsb = 38h
+opc_pminsd = 39h
+opc_pminud = 3Bh
+opc_pminuw = 3Ah
+opc_pmovsxbw = 20h
+opc_pmovsxbd = 21h
+opc_pmovsxbq = 22h
+opc_pmovsxwd = 23h
+opc_pmovsxwq = 24h
+opc_pmovsxdq = 25h
+opc_pmovzxbw = 30h
+opc_pmovzxbd = 31h
+opc_pmovzxbq = 32h
+opc_pmovzxwd = 33h
+opc_pmovzxwq = 34h
+opc_pmovzxdq = 35h
+opc_pmuldq = 28h
+opc_pmulld = 40h
+opc_ptest = 17h
+opc_roundpd = 09h
+opc_roundps = 08h
+opc_roundsd = 0Bh
+opc_roundss = 0Ah
+
+sni_instruction macro dst:req, src:req, nis:req, opc:req, imm8
+ local x0, x1, x2, x3, x4, x5, x6, x7
+
+ bracket INSTR <src>,<[>
+ IF bracket GT 0
+ memtype INSTR <src>,<oword>
+ IF memtype EQ 0
+ memtype INSTR <src>,<OWORD>
+ ENDIF
+ IF memtype EQ 0
+ .ERR <src must contain: oword ptr >
+ EXITM
+ ENDIF
+ ENDIF
+ bracket INSTR <dst>,<[>
+ IF bracket GT 0
+ memtype INSTR <dst>,<oword>
+ IF memtype EQ 0
+ memtype INSTR <dst>,<OWORD>
+ ENDIF
+ IF memtype EQ 0
+ .ERR <dst must contain: oword ptr >
+ EXITM
+ ENDIF
+ ENDIF
+ IS_REX <src>,REX ; do we need REX byte due to src operand?
+ REXS = REX
+ IF REXS EQ 1 ; if yes - we have to prepare substitution in order
+ s1rc textequ SUBST_HIGH( src ) ; to work correctly with direct memory operands
+ ELSE
+ s1rc textequ <src> ; else substitution is not required
+ ENDIF
+ IS_REX <dst>,REX ; do we need REX byte due to dst operand?
+ REXD = REX
+ IF REXD EQ 1 ; if yes - we have to prepare substitution in order
+ d1st textequ SUBST_HIGH( dst ) ; to work correctly with direct memory operands
+ ELSE
+ d1st textequ <dst> ; else substitution is not required
+ ENDIF
+ REX = REXS + REXD
+ NAMS = IS_NAME( src ) ; is there the direct memory operand (defined by name in code
+ NAMD = IS_NAME( dst ) ; or data section)? if yes - then another algorithm for macro
+ isname = NAMS + NAMD ; substitution due to bug in ml with relocations definition
+ s2rc textequ SUBST_MIMM( src, xmm0 )
+ d2st textequ SUBST_MIMM( dst, xmm0 )
+ IF isname GT 0 ; if src or dst contains direct reference to memory operand
+ IF REX GT 0
+ db reg_xmm
+ x0:
+ nop
+ nop
+ movaps d1st,s1rc ; 66 90 90 0F 28 /r m32
+ x1:
+ org x0
+ movaps d2st,s2rc ; 66 REX 0F 28 /r /r m32
+ org x0+2
+ db nis
+ db opc
+ IFNB <imm8>
+ org x0+5
+ dd 0FFFFFFFFH
+ org x1 ; 66 REX 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x1
+ ENDIF
+ ELSE
+ db reg_xmm
+ x2:
+ nop
+ movaps dst, src ; 66 90 0F 28 /r m32
+ x3:
+ org x2
+ db reg_mmx
+ db nis
+ db opc
+ IFNB <imm8>
+ org x2+4
+ dd 0FFFFFFFFH
+ org x3 ; 66 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x3
+ ENDIF
+ ENDIF
+ ELSE ; if src or dst doesn't contain direct reference to memory operand
+ IF REX GT 0
+ db reg_xmm
+ x4:
+ movaps dst,src ; 66 REX 0F 28 /r
+ org x4+1
+ movaps dst,src ; 66 REX REX 0F 28 /r
+ x5:
+ org x4+1
+ db reg_mmx
+ db nis
+ db opc
+ org x5 ; 66 REX 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ELSE
+ db reg_xmm
+ x6:
+ nop
+ movaps dst, src ; 66 90 0F 28 /r
+ x7:
+ org x6
+ db reg_mmx
+ db nis
+ db opc
+ org x7 ; 66 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ENDIF
+ ENDIF
+endm
+
+DO_NEED_REX MACRO x, gpr32_64, rexbyte ; test if REX required for pextrw instr (old form)
+ gpr32_64 = 0 ; gpr32_64 shows what gpr is required for substitution - 32bit or 64bit
+ rexbyte = 0 ; if REX is required than rexbyte = 1
+ %FOR ygpr,HIGHD_GPR
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ gpr32_64 = 0
+ rexbyte = 1
+ EXITM
+ ENDIF ; if posgpr > 0
+ ENDM ; for ygpr
+ IF rexbyte GT 0
+ EXITM
+ ENDIF
+ %FOR ygpr,HIGHQ_GPR
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ gpr32_64 = 1
+ rexbyte = 1
+ EXITM
+ ENDIF ; if posgpr > 0
+ ENDM ; for ygpr
+ IF rexbyte GT 0
+ EXITM
+ ENDIF
+ %FOR ygpr,LOWQ_GPR
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ gpr32_64 = 1
+ rexbyte = 1
+ EXITM
+ ENDIF ; if posgpr > 0
+ ENDM ; for ygpr
+ENDM
+
+REPLACE_MMX MACRO x, gpr32_64 ; this macro substites any mmx register (in order to use mov r32/64,r32/64 instr)
+ xretgpr textequ <x> ; with the gpr equivalent (with the same index in mod/r/m byte) for pextrw instr
+ qgpr = 0
+ %FOR ygpr,ALL_MMX
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ IF gpr32_64 GT 0
+ fgpr = 0
+ %FOR zgpr,LOWQ_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ELSE ; gpr 32 or 64
+ fgpr = 0
+ %FOR zgpr,LOWD_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; gpr 32 or 64
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ EXITM xretgpr
+ENDM
+
+REPLACE_XMM MACRO x, gpr32_64 ; this macro substites any xmm register (in order to use mov r32/64,r32/64 instr)
+ xretgpr textequ <x> ; with the gpr equivalent (with the same index in mod/r/m byte) for extr/insr instr
+ yesfound = 0
+ qgpr = 0
+ %FOR ygpr,LOW_XMM
+ IFIDN <ygpr>,<x>
+ IF gpr32_64 GT 0
+ fgpr = 0
+ %FOR zgpr,LOWQ_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ yesfound = 1
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ELSE ; gpr 32 or 64
+ fgpr = 0
+ %FOR zgpr,LOWD_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ yesfound = 1
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; gpr 32 or 64
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ IF yesfound GT 0
+ EXITM xretgpr
+ ENDIF
+ qgpr = 0
+ %FOR ygpr,HIGH_XMM
+ IFIDN <ygpr>,<x>
+ IF gpr32_64 GT 0
+ fgpr = 0
+ %FOR zgpr,HIGHQ_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ yesfound = 1
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ELSE ; gpr 32 or 64
+ fgpr = 0
+ %FOR zgpr,HIGHD_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ yesfound = 1
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; gpr 32 or 64
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ EXITM xretgpr
+ENDM
+
+sni_instr_gpr_new macro dst:req, src:req, nis:req, opc:req, imm8
+ local x1, y1, x2, y2
+ gpr32_64_d = 0 ; 32-bit or 64-bit form is used?
+ rexbyte_d = 0
+ gpr32_64_s = 0 ; 32-bit or 64-bit form is used?
+ rexbyte_s = 0
+ DO_NEED_REX dst, gpr32_64_d, rexbyte_d ; test for if REX byte is required
+ IS_REX <dst>,REX ; do we need REX byte due to dst operand?
+ REXD = REX + rexbyte_d
+ DO_NEED_REX src, gpr32_64_s, rexbyte_s ; test for if REX byte is required
+ IS_REX <src>,REX ; do we need REX byte due to dst operand?
+ REXS = REX + rexbyte_s
+ REX = REXS + REXD
+ gpr32_64 = gpr32_64_s + gpr32_64_d
+ s2rc textequ REPLACE_XMM( src, gpr32_64 ) ; substite src xmm register with gpr that has the same index in mod/r/m byte
+ d2st textequ REPLACE_XMM( dst, gpr32_64 ) ; substite dst xmm register with gpr that has the same index in mod/r/m byte
+ IF REX GT 0
+ db 66h
+ x1:
+;%echo @CatStr( <r in d1= >,<dst>,< s1=>,<src>)
+;%echo @CatStr( <r out d1= >,<d2st>,< s1=>,<s2rc>)
+ mov d2st, s2rc ; 66 REX 8B /r
+ org x1+2
+ mov d2st, s2rc ; 66 REX 8B REX 8B /r
+ y1:
+ org x1+1
+ db 0Fh
+ db nis
+ db opc ; 66 REX 0F nis opc /r
+ org y1
+ ELSE
+ db 66h
+ db 0Fh
+ db nis
+ x2:
+;%echo @CatStr( <nr in d1= >,<dst>,< s1=>,<src>)
+;%echo @CatStr( <nr out d1= >,<d2st>,< s1=>,<s2rc>)
+ mov d2st, s2rc ; 66 0F nis 8B /r
+ y2:
+ org x2
+ db opc ; 66 0F nis opc /r
+ org y2
+ ENDIF
+ db imm8 ; 66 <REX> 0F nis opc /r
+endm
+
+IS_GPRDQ MACRO x, GPRDQ
+ GPRDQ = 0
+ %FOR ygprdq,HIGHDQ_GPR
+ IF @InStr( , x, ygprdq ) NE 0
+ GPRDQ = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF GPRDQ EQ 0
+ %FOR ygprdq,LOWDQ_GPR
+ IF @InStr( , x, ygprdq ) NE 0
+ GPRDQ = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ENDM
+
+IS_XMMALL MACRO x, GPRDQ
+ GPRDQ = 0
+ %FOR yxmmall,HIGH_XMM
+ IFIDN <yxmmall>,<x>
+ GPRDQ = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF GPRDQ EQ 0
+ %FOR yxmmall,LOW_XMM
+ IFIDN <yxmmall>,<x>
+ GPRDQ = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ENDM
+
+sni_instr_src_m_gpr macro dst:req, src:req, nis:req, opc:req, mem:req, imm8
+ IFIDN <mem>,<m8>
+ memlc textequ <byte>
+ memuc textequ <BYTE>
+ ENDIF
+ IFIDN <mem>,<m16>
+ memlc textequ <word>
+ memuc textequ <WORD>
+ ENDIF
+ IFIDN <mem>,<m32>
+ memlc textequ <dword>
+ memuc textequ <DWORD>
+ ENDIF
+ IFIDN <mem>,<m64>
+ memlc textequ <qword>
+ memuc textequ <QWORD>
+ ENDIF
+ src_dup textequ <src>
+ bracket INSTR <src>,<[>
+ IF bracket EQ 0
+ bracket INSTR <src>,<ptr>
+ ENDIF
+ IF bracket EQ 0
+ bracket INSTR <src>,<PTR>
+ ENDIF
+ IF bracket GT 0
+ memtype INSTR <src>,memlc
+ IF memtype EQ 0
+ memtype INSTR <src>,memuc
+ ENDIF
+ IF memtype GT 0
+ f1mem SUBSTR <src>, 1, memtype - 1
+ f2mem SUBSTR <src>, memtype + @SizeStr( memlc )
+ src_dup CATSTR <f1mem>, < oword >, <f2mem>
+ sni_instruction dst, %src_dup, nis, opc, imm8
+ ELSE
+ .ERR <must be: &memlc ptr >
+ EXITM
+ ENDIF
+ ELSE
+ IS_GPRDQ src, GPRDQ
+ IF GPRDQ EQ 0
+ .ERR <bad source operand>
+ ELSE
+ sni_instr_gpr_new dst, src, nis, opc, imm8
+ ENDIF
+ ENDIF
+endm
+
+sni_instr_src_m_xmm macro dst:req, src:req, nis:req, opc:req, mem:req, imm8
+ IFIDN <mem>,<m8>
+ memlc textequ <byte>
+ memuc textequ <BYTE>
+ ENDIF
+ IFIDN <mem>,<m16>
+ memlc textequ <word>
+ memuc textequ <WORD>
+ ENDIF
+ IFIDN <mem>,<m32>
+ memlc textequ <dword>
+ memuc textequ <DWORD>
+ ENDIF
+ IFIDN <mem>,<m64>
+ memlc textequ <qword>
+ memuc textequ <QWORD>
+ ENDIF
+ src_dup textequ <src>
+ bracket INSTR <src>,<[>
+ IF bracket EQ 0
+ bracket INSTR <src>,<ptr>
+ ENDIF
+ IF bracket EQ 0
+ bracket INSTR <src>,<PTR>
+ ENDIF
+ IF bracket GT 0
+ memtype INSTR <src>,memlc
+ IF memtype EQ 0
+ memtype INSTR <src>,memuc
+ ENDIF
+ IF memtype GT 0
+ f1mem SUBSTR <src>, 1, memtype - 1
+ f2mem SUBSTR <src>, memtype + @SizeStr( memlc )
+ src_dup CATSTR <f1mem>, < oword >, <f2mem>
+ sni_instruction dst, %src_dup, nis, opc, imm8
+ ELSE
+ .ERR <must be: &memlc ptr >
+ EXITM
+ ENDIF
+ ELSE
+ IS_XMMALL src, GPRDQ
+ IF GPRDQ EQ 0
+ .ERR <bad source operand>
+ ELSE
+ sni_instruction dst, src, nis, opc, imm8
+ ENDIF
+ ENDIF
+endm
+
+sni_instr_dst_m_gpr macro dst:req, src:req, nis:req, opc:req, mem:req, imm8
+ IFIDN <mem>,<m8>
+ memlc textequ <byte>
+ memuc textequ <BYTE>
+ ENDIF
+ IFIDN <mem>,<m16>
+ memlc textequ <word>
+ memuc textequ <WORD>
+ ENDIF
+ IFIDN <mem>,<m32>
+ memlc textequ <dword>
+ memuc textequ <DWORD>
+ ENDIF
+ IFIDN <mem>,<m64>
+ memlc textequ <qword>
+ memuc textequ <QWORD>
+ ENDIF
+ dst_dup textequ <dst>
+ bracket INSTR <dst>,<[>
+ IF bracket EQ 0
+ bracket INSTR <dst>,<ptr>
+ ENDIF
+ IF bracket EQ 0
+ bracket INSTR <dst>,<PTR>
+ ENDIF
+ IF bracket GT 0
+ memtype INSTR <dst>,memlc
+ IF memtype EQ 0
+ memtype INSTR <dst>,memuc
+ ENDIF
+ IF memtype GT 0
+ f1mem SUBSTR <dst>, 1, memtype - 1
+ f2mem SUBSTR <dst>, memtype + @SizeStr( memlc )
+ dst_dup CATSTR <f1mem>, < oword >, <f2mem>
+ sni_instruction src, %dst_dup, nis, opc, imm8
+ ELSE
+ .ERR <must be: &memlc ptr >
+ EXITM
+ ENDIF
+ ELSE
+ IS_GPRDQ dst, GPRDQ
+ IF GPRDQ EQ 0
+ .ERR <bad destination operand>
+ ELSE
+ sni_instr_gpr_new src, dst, nis, opc, imm8
+ ENDIF
+ ENDIF
+endm
+
+;IF @Version LT 900
+IFNDEF D_ML900
+
+; OPTION NOKEYWORD:<blendpd>
+; 66 0F 3A 0D blendpd xmm1, xmm2/m128, imm8
+blendpd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_blendpd, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<blendps>
+; 66 0F 3A 0C blendps xmm1, xmm2/m128, imm8
+blendps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_blendps, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<blendvpd>
+; 66 0F 38 15 blendvpd xmm1, xmm2/m128, XMM0
+blendvpd macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_blendvpd
+endm
+
+; OPTION NOKEYWORD:<blendvps>
+; 66 0F 38 14 blendvps xmm1, xmm2/m128, XMM0
+blendvps macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_blendvps
+endm
+
+; OPTION NOKEYWORD:<dppd>
+; 66 0F 3A 41 dppd xmm1, xmm2/m128, imm8
+dppd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_dppd, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<dpps>
+; 66 0F 3A 40 dpps xmm1, xmm2/m128, imm8
+dpps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_dpps, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<extractps>
+; 66 0F 3A 17 extractps r/m32, xmm2, imm8
+extractps macro dst:req, src:req, imm8:req
+ %sni_instr_dst_m_gpr dst, src, nis_snia, opc_extractps, m32, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<insertps>
+; 66 0F 3A 21 insertps xmm1, xmm2/m32, imm8
+insertps macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_xmm dst, src, nis_snia, opc_insertps, m32, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<movntdqa>
+; 66 0F 38 2A movntdqa xmm1, m128
+movntdqa macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_movntdqa
+endm
+
+; OPTION NOKEYWORD:<mpsadbw>
+; 66 0F 3A 42 mpsadbw xmm1, xmm2/m32, imm8
+mpsadbw macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_mpsadbw, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<packusdw>
+; 66 0F 38 2B packusdw xmm1, xmm2/m128
+packusdw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_packusdw
+endm
+
+; OPTION NOKEYWORD:<pblendvb>
+; 66 0F 38 10 pblendvb xmm1, xmm2/m128, XMM0
+pblendvb macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_pblendvb
+endm
+
+; OPTION NOKEYWORD:<pblendw>
+; 66 0F 3A 0E pblendw xmm1, xmm2/m128, imm8
+pblendw macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_pblendw, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pcmpeqq>
+; 66 0F 38 29 pcmpeqq xmm1, xmm2/m128
+pcmpeqq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pcmpeqq
+endm
+
+; OPTION NOKEYWORD:<pextrb>
+; 66 0F 3A 14 pextrb r32/m8, xmm2, imm8
+pextrb macro dst:req, src:req, imm8:req
+ %sni_instr_dst_m_gpr dst, src, nis_snia, opc_pextrb, m8, imm8
+; db imm8
+endm
+
+
+IF _IPP32E GE _IPP32E_Y8
+
+
+ OPTION NOKEYWORD:<pextrw>
+; 66 0F 3A 15 pextrw r32/m16, xmm2, imm8
+pextrw macro dst:req, src:req, imm8:req
+ local x1, y1, x2, y2
+ IFMMX_REG src, f ; if mmx register - old (P4) coding should be used
+ IF f GT 0
+ gpr32_64 = 0 ; 32-bit or 64-bit form is used?
+ rexbyte = 0
+ DO_NEED_REX dst, gpr32_64, rexbyte ; test for if REX byte is required
+ s2rc textequ REPLACE_MMX( src, gpr32_64 ) ; substite source mmx register with gpr that has the same index in mod/r/m byte
+ IF rexbyte GT 0
+ x1:
+ mov dst, s2rc ; REX 8B /r
+ org x1+1
+ mov dst, s2rc ; REX REX 8B /r
+ y1:
+ org x1+1
+ db 0Fh
+ db 0C5h ; REX 0F C5 /r
+ org y1
+ ELSE
+ x2:
+ nop
+ mov dst, s2rc ; 90 8B /r
+ y2:
+ org x2
+ db 0Fh
+ db 0C5h ; 0F C5 /r
+ org y2
+ ENDIF
+ db imm8 ; 0F C5 /r imm8
+ ELSE
+ %sni_instr_dst_m_gpr dst, src, nis_snia, opc_pextrw, m16, imm8
+ ENDIF
+endm
+ENDIF
+
+; OPTION NOKEYWORD:<pextrd>
+; 66 0F 3A 16 pextrd r32/m32, xmm2, imm8
+pextrd macro dst:req, src:req, imm8:req
+ %sni_instr_dst_m_gpr dst, src, nis_snia, opc_pextrd, m32, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pextrq>
+; 66 REX 0F 3A 16 pextrq r64/m64, xmm2, imm8
+pextrq macro dst:req, src:req, imm8:req
+ %sni_instr_dst_m_gpr dst, src, nis_snia, opc_pextrd, m64, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<phminposuw>
+; 66 0F 38 41 phminposuw xmm1, xmm2/m128
+phminposuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_phminposuw
+endm
+
+; OPTION NOKEYWORD:<pinsrb>
+; 66 0F 3A 20 pinsrb xmm1, r32/m8, imm8
+pinsrb macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_gpr dst, src, nis_snia, opc_pinsrb, m8, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pinsrd>
+; 66 0F 3A 22 pinsrd xmm1, r32/m32, imm8
+pinsrd macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_gpr dst, src, nis_snia, opc_pinsrd, m32, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pinsrq>
+; 66 REX 0F 3A 22 pinsrq xmm1, r64/m64, imm8
+pinsrq macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_gpr dst, src, nis_snia, opc_pinsrd, m64, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<pmaxsb>
+; 66 0F 38 3C pmaxsb xmm1, xmm2/m128
+pmaxsb macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxsb
+endm
+
+; OPTION NOKEYWORD:<pmaxsd>
+; 66 0F 38 3D pmaxsd xmm1, xmm2/m128
+pmaxsd macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxsd
+endm
+
+; OPTION NOKEYWORD:<pmaxud>
+; 66 0F 38 3F pmaxud xmm1, xmm2/m128
+pmaxud macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxud
+endm
+
+; OPTION NOKEYWORD:<pmaxuw>
+; 66 0F 38 3E pmaxuw xmm1, xmm2/m128
+pmaxuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxuw
+endm
+
+; OPTION NOKEYWORD:<pminsb>
+; 66 0F 38 38 pminsb xmm1, xmm2/m128
+pminsb macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminsb
+endm
+
+; OPTION NOKEYWORD:<pminsd>
+; 66 0F 38 39 pminsd xmm1, xmm2/m128
+pminsd macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminsd
+endm
+
+; OPTION NOKEYWORD:<pminud>
+; 66 0F 38 3B pminud xmm1, xmm2/m128
+pminud macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminud
+endm
+
+; OPTION NOKEYWORD:<pminuw>
+; 66 0F 38 3A pminuw xmm1, xmm2/m128
+pminuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminuw
+endm
+
+; OPTION NOKEYWORD:<pmovsxbw>
+; 66 0F 38 20 pmovsxbw xmm1, xmm2/m64
+pmovsxbw macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxbw, m64
+endm
+
+; OPTION NOKEYWORD:<pmovsxbd>
+; 66 0F 38 21 pmovsxbd xmm1, xmm2/m32
+pmovsxbd macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxbd, m32
+endm
+
+; OPTION NOKEYWORD:<pmovsxbq>
+; 66 0F 38 22 pmovsxbq xmm1, xmm2/m16
+pmovsxbq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxbq, m16
+endm
+
+; OPTION NOKEYWORD:<pmovsxwd>
+; 66 0F 38 23 pmovsxwd xmm1, xmm2/m64
+pmovsxwd macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxwd, m64
+endm
+
+; OPTION NOKEYWORD:<pmovsxwq>
+; 66 0F 38 24 pmovsxwq xmm1, xmm2/m32
+pmovsxwq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxwq, m32
+endm
+
+; OPTION NOKEYWORD:<pmovsxdq>
+; 66 0F 38 25 pmovsxdq xmm1, xmm2/m64
+pmovsxdq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovsxdq, m64
+endm
+
+; OPTION NOKEYWORD:<pmovzxbw>
+; 66 0F 38 30 pmovzxbw xmm1, xmm2/m64
+pmovzxbw macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxbw, m64
+endm
+
+; OPTION NOKEYWORD:<pmovzxbd>
+; 66 0F 38 31 pmovzxbd xmm1, xmm2/m32
+pmovzxbd macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxbd, m32
+endm
+
+; OPTION NOKEYWORD:<pmovzxbq>
+; 66 0F 38 32 pmovzxbq xmm1, xmm2/m16
+pmovzxbq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxbq, m16
+endm
+
+; OPTION NOKEYWORD:<pmovzxwd>
+; 66 0F 38 33 pmovzxwd xmm1, xmm2/m64
+pmovzxwd macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxwd, m64
+endm
+
+; OPTION NOKEYWORD:<pmovzxwq>
+; 66 0F 38 34 pmovzxwq xmm1, xmm2/m32
+pmovzxwq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxwq, m32
+endm
+
+; OPTION NOKEYWORD:<pmovzxdq>
+; 66 0F 38 35 pmovzxdq xmm1, xmm2/m64
+pmovzxdq macro dst:req, src:req
+ %sni_instr_src_m_xmm dst, src, nis_sni, opc_pmovzxdq, m64
+endm
+
+; OPTION NOKEYWORD:<pmuldq>
+; 66 0F 38 28 pmuldq xmm1, xmm2/m128
+pmuldq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmuldq
+endm
+
+; OPTION NOKEYWORD:<pmulld>
+; 66 0F 38 40 pmulld xmm1, xmm2/m128
+pmulld macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmulld
+endm
+
+; OPTION NOKEYWORD:<ptest>
+; 66 0F 38 17 ptest xmm1, xmm2/m128
+ptest macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_ptest
+endm
+
+; OPTION NOKEYWORD:<roundpd>
+; 66 0F 3A 09 roundpd xmm1, xmm2/m128, imm8
+roundpd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_roundpd, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<roundps>
+; 66 0F 3A 08 roundps xmm1, xmm2/m128, imm8
+roundps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_roundps, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<roundsd>
+; 66 0F 3A 0B roundsd xmm1, xmm2/m64, imm8
+roundsd macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_xmm dst, src, nis_snia, opc_roundsd, m64, imm8
+; db imm8
+endm
+
+; OPTION NOKEYWORD:<roundss>
+; 66 0F 3A 0A roundss xmm1, xmm2/m32, imm8
+roundss macro dst:req, src:req, imm8:req
+ %sni_instr_src_m_xmm dst, src, nis_snia, opc_roundss, m32, imm8
+; db imm8
+endm
+
+; STTNI (SSE4.2)
+
+nis_sttni = 38h ; new instruction set
+nis_sttnia = 3Ah ; new instruction set 'a' (with imm8)
+
+opc_pcmpestri = 61h
+opc_pcmpestrm = 60h
+opc_pcmpistri = 63h
+opc_pcmpistrm = 62h
+opc_pcmpgtq = 37h
+opc_crc32_m8 = 0F0h
+opc_crc32 = 0F1h
+
+; 66 0F 3A 61 pcmpestri xmm1, xmm2/m128, imm8
+pcmpestri macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpestri, imm8
+endm
+
+; 66 0F 3A 60 pcmpestrm xmm1, xmm2/m128, imm8
+pcmpestrm macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpestrm, imm8
+endm
+
+; 66 0F 3A 63 pcmpistri xmm1, xmm2/m128, imm8
+pcmpistri macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpistri, imm8
+endm
+
+; 66 0F 3A 62 pcmpistrm xmm1, xmm2/m128, imm8
+pcmpistrm macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpistrm, imm8
+endm
+
+; 66 0F 38 37 pcmpgtq xmm1, xmm2/m128
+pcmpgtq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_pcmpgtq
+endm
+
+
+; WSM (AES NI)
+
+opc_aesenc = 0DCh
+opc_aesenclast = 0DDh
+opc_aesdec = 0DEh
+opc_aesdeclast = 0DFh
+opc_aesimc = 0DBh
+opc_aeskeygenassist = 0DFh
+opc_pclmulqdq = 044h
+
+; 66 0F 38 DC aesenc xmm1, xmm2/m128
+aesenc macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesenc
+endm
+
+; 66 0F 38 DD aesenclast xmm1, xmm2/m128
+aesenclast macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesenclast
+endm
+
+; 66 0F 38 DE aesdec xmm1, xmm2/m128
+aesdec macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesdec
+endm
+
+; 66 0F 38 DF aesdeclast xmm1, xmm2/m128
+aesdeclast macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesdeclast
+endm
+
+; 66 0F 38 DB aesimc xmm1, xmm2/m128
+aesimc macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesimc
+endm
+
+; 66 0F 3A DF aeskeygenassist xmm1, xmm2/m128, imm8
+aeskeygenassist macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_aeskeygenassist, imm8
+endm
+
+; 66 0F 3A 44 pclmulqdq xmm1, xmm2/m128, imm8
+pclmulqdq macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pclmulqdq, imm8
+endm
+
+ENDIF
+
+; AVX 2.0 NI
+
+get3rdbyte MACRO reg:req, opc3:req
+ IS_XMMALL reg, x
+ IF x EQ 0
+ opc3 = 085H
+ ELSE
+ opc3 = 081H
+ ENDIF
+ %FOR num,ALL_NUM
+ IF @InStr( , reg, num ) NE 0
+ EXITM
+ ENDIF
+ opc3 = opc3 + 8
+ ENDM
+endm
+
+avx20_double MACRO op1:req, op2:req, op3:req, opc:req
+ local x0, x1
+ x0:
+ vpermilpd op1, op2, op3
+ x1:
+ org x0+2
+ get3rdbyte <op2>, opc3
+ db opc3
+ db opc
+ org x1
+endm
+
+avx20_float MACRO op1:req, op2:req, op3:req, opc:req
+local x0, x1
+ x0:
+ vpermilps op1, op2, op3
+ x1:
+ org x0+3
+ db opc
+ org x1
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 98 /r VFMADD132PD xmm0, xmm1, xmm2/m128
+vfmadd132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 98H
+endm
+; VEX.DDS.128/256.66.0F38.W1 A8 /r VFMADD213PD xmm0, xmm1, xmm2/m128
+vfmadd213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0A8H
+endm
+; VEX.DDS.128/256.66.0F38.W1 B8 /r VFMADD231PD xmm0, xmm1, xmm2/m128
+vfmadd231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0B8H
+endm
+; VEX.DDS.128/256.66.0F38.W0 98 /r VFMADD132PS xmm0, xmm1, xmm2/m128
+vfmadd132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 98H
+endm
+; VEX.DDS.128/256.66.0F38.W0 A8 /r VFMADD213PS xmm0, xmm1, xmm2/m128
+vfmadd213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0A8H
+endm
+; VEX.DDS.128/256.66.0F38.W0 B8 /r VFMADD231PS xmm0, xmm1, xmm2/m128
+vfmadd231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0B8H
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 99 /r VFMADD132SD xmm0, xmm1, xmm2/m128
+vfmadd132sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 99H
+endm
+; VEX.DDS.128/256.66.0F38.W1 A9 /r VFMADD213SD xmm0, xmm1, xmm2/m128
+vfmadd213sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0A9H
+endm
+; VEX.DDS.128/256.66.0F38.W1 B9 /r VFMADD231SD xmm0, xmm1, xmm2/m128
+vfmadd231sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0B9H
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 99 /r VFMADD132SS xmm0, xmm1, xmm2/m128
+vfmadd132ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 99H
+endm
+; VEX.DDS.128/256.66.0F38.W0 A9 /r VFMADD213SS xmm0, xmm1, xmm2/m128
+vfmadd213ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0A9H
+endm
+; VEX.DDS.128/256.66.0F38.W0 B9 /r VFMADD231SS xmm0, xmm1, xmm2/m128
+vfmadd231ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0B9H
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 96 /r VFMADDSUB132PD xmm0, xmm1, xmm2/m128
+vfmaddsub132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 96H
+endm
+; VEX.DDS.128/256.66.0F38.W1 A6 /r VFMADDSUB213PD xmm0, xmm1, xmm2/m128
+vfmaddsub213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0A6H
+endm
+; VEX.DDS.128/256.66.0F38.W1 B6 /r VFMADDSUB231PD xmm0, xmm1, xmm2/m128
+vfmaddsub231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0B6H
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 96 /r VFMADDSUB132PS xmm0, xmm1, xmm2/m128
+vfmaddsub132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 96H
+endm
+; VEX.DDS.128/256.66.0F38.W0 A6 /r VFMADDSUB213PS xmm0, xmm1, xmm2/m128
+vfmaddsub213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0A6H
+endm
+; VEX.DDS.128/256.66.0F38.W0 B6 /r VFMADDSUB231PS xmm0, xmm1, xmm2/m128
+vfmaddsub231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0B6H
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 97 /r VFMSUBADD132PD xmm0, xmm1, xmm2/m128
+vfmsubadd132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 97H
+endm
+; VEX.DDS.128/256.66.0F38.W1 A7 /r VFMSUBADD213PD xmm0, xmm1, xmm2/m128
+vfmsubadd213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0A7H
+endm
+; VEX.DDS.128/256.66.0F38.W1 B7 /r VFMSUBADD231PD xmm0, xmm1, xmm2/m128
+vfmsubadd231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0B7H
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 97 /r VFMSUBADD132PS xmm0, xmm1, xmm2/m128
+vfmsubadd132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 97H
+endm
+; VEX.DDS.128/256.66.0F38.W0 A7 /r VFMSUBADD213PS xmm0, xmm1, xmm2/m128
+vfmsubadd213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0A7H
+endm
+; VEX.DDS.128/256.66.0F38.W0 B7 /r VFMSUBADD231PS xmm0, xmm1, xmm2/m128
+vfmsubadd231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0B7H
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9A /r VFMSUB132PD xmm0, xmm1, xmm2/m128
+vfmsub132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9AH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AA /r VFMSUB213PD xmm0, xmm1, xmm2/m128
+vfmsub213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0AAH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BA /r VFMSUB231PD xmm0, xmm1, xmm2/m128
+vfmsub231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BAH
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 9A /r VFMSUB132PS xmm0, xmm1, xmm2/m128
+vfmsub132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9AH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AA /r VFMSUB213PS xmm0, xmm1, xmm2/m128
+vfmsub213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0AAH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BA /r VFMSUB231PS xmm0, xmm1, xmm2/m128
+vfmsub231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BAH
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9B /r VFMSUB132SD xmm0, xmm1, xmm2/m128
+vfmsub132sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9BH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AB /r VFMSUB213SD xmm0, xmm1, xmm2/m128
+vfmsub213sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0ABH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BB /r VFMSUB231SD xmm0, xmm1, xmm2/m128
+vfmsub231sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BBH
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 9B /r VFMSUB132SS xmm0, xmm1, xmm2/m128
+vfmsub132ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9BH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AB /r VFMSUB213SS xmm0, xmm1, xmm2/m128
+vfmsub213ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0ABH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BB /r VFMSUB231SS xmm0, xmm1, xmm2/m128
+vfmsub231ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BBH
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9C /r VFNMADD132PD xmm0, xmm1, xmm2/m128
+vfnmadd132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9CH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AC /r VFNMADD213PD xmm0, xmm1, xmm2/m128
+vfnmadd213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0ACH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BC /r VFNMADD231PD xmm0, xmm1, xmm2/m128
+vfnmadd231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BCH
+endm
+; VEX.DDS.128/256.66.0F38.W0 9C /r VFNMADD132PS xmm0, xmm1, xmm2/m128
+vfnmadd132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9CH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AC /r VFNMADD213PS xmm0, xmm1, xmm2/m128
+vfnmadd213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0ACH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BC /r VFNMADD231PS xmm0, xmm1, xmm2/m128
+vfnmadd231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BCH
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9D /r VFNMADD132SD xmm0, xmm1, xmm2/m128
+vfnmadd132sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9DH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AD /r VFNMADD213SD xmm0, xmm1, xmm2/m128
+vfnmadd213sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0ADH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BD /r VFNMADD231SD xmm0, xmm1, xmm2/m128
+vfnmadd231sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BDH
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 9D /r VFNMADD132SS xmm0, xmm1, xmm2/m128
+vfnmadd132ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9DH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AD /r VFNMADD213SS xmm0, xmm1, xmm2/m128
+vfnmadd213ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0ADH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BD /r VFNMADD231SS xmm0, xmm1, xmm2/m128
+vfnmadd231ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BDH
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9E /r VFNMSUB132PD xmm0, xmm1, xmm2/m128
+vfnmsub132pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9EH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AE /r VFNMSUB213PD xmm0, xmm1, xmm2/m128
+vfnmsub213pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0AEH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BE /r VFNMSUB231PD xmm0, xmm1, xmm2/m128
+vfnmsub231pd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BEH
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 9E /r VFNMSUB132PS xmm0, xmm1, xmm2/m128
+vfnmsub132ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9EH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AE /r VFNMSUB213PS xmm0, xmm1, xmm2/m128
+vfnmsub213ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0AEH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BE /r VFNMSUB231PS xmm0, xmm1, xmm2/m128
+vfnmsub231ps macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BEH
+endm
+
+; VEX.DDS.128/256.66.0F38.W1 9F /r VFNMSUB132SD xmm0, xmm1, xmm2/m128
+vfnmsub132sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 9FH
+endm
+; VEX.DDS.128/256.66.0F38.W1 AF /r VFNMSUB213SD xmm0, xmm1, xmm2/m128
+vfnmsub213sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0AFH
+endm
+; VEX.DDS.128/256.66.0F38.W1 BF /r VFNMSUB231SD xmm0, xmm1, xmm2/m128
+vfnmsub231sd macro x:req, y:req, z:req
+ %avx20_double x, y, z, 0BFH
+endm
+
+; VEX.DDS.128/256.66.0F38.W0 9F /r VFNMSUB132SS xmm0, xmm1, xmm2/m128
+vfnmsub132ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 9FH
+endm
+; VEX.DDS.128/256.66.0F38.W0 AF /r VFNMSUB213SS xmm0, xmm1, xmm2/m128
+vfnmsub213ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0AFH
+endm
+; VEX.DDS.128/256.66.0F38.W0 BF /r VFNMSUB231SS xmm0, xmm1, xmm2/m128
+vfnmsub231ss macro x:req, y:req, z:req
+ %avx20_float x, y, z, 0BFH
+endm
+
+; substitution because of a bug in ml10.0 version 10.00.30128.01
+; VEX.256.66.0F3A 19 /r ib
+ OPTION NOKEYWORD:< vextractf128>
+ vextractf128 macro xx:req, yy:req, imm:req
+ local x1, x2, q, f, z, memoprndl, memoprndu, memopl, memopu
+ memoprndl textequ <word>
+ memoprndu textequ <WORD>
+ memopl INSTR <xx>, memoprndl
+ memopu INSTR <xx>, memoprndu
+ IF (memopl+memopu) GT 0
+ q textequ <ymm>
+ f SUBSTR <xx>, 2
+ z CATSTR q, f
+ ELSE
+ q textequ <y>
+ f SUBSTR <xx>, 2
+ z CATSTR q, f
+ ENDIF
+ x1:
+ vpermilpd yy, z, imm
+ x2:
+ org x1+3
+ db 19H
+ org x2
+ endm
+; AVX2 (HSW)
+
+getW0W1 MACRO reg:req, opc3:req, w0w1:req
+ IS_XMMALL reg, x
+ IF x EQ 0
+ opc3 = 085H
+ ELSE
+ opc3 = 081H
+ ENDIF
+ %FOR num,ALL_NUM
+ IF @InStr( , reg, num ) NE 0
+ EXITM
+ ENDIF
+ opc3 = opc3 + 8
+ ENDM
+ IF w0w1 EQ 0
+ opc3 = opc3 - 80H
+ ENDIF
+endm
+
+;VEX.NDS.128.66.0F38.W0 47 /r
+vpsllvd MACRO op1:req, op2:req, op3:req
+local x0, x1
+ x0:
+ vpermilps op1, op2, op3
+ x1:
+ org x0+3
+ db 47H
+ org x1
+endm
+
+;VEX.NDS.128.66.0F38.W1 47 /r
+vpsllvq MACRO op1:req, op2:req, op3:req
+local x0, x1
+ x0:
+ vpermilps op1, op2, op3
+ x1:
+ org x0+2
+ getW0W1 <op2>, opc3, 1
+ db opc3
+ db 47H
+ org x1
+endm
+ENDIF ; IFNDEF ML1100
+
+;IFNDEF ML1200
+; BDW MACRO for ML1100 adox & adcx
+
+ALL_XMM textequ <!<xmm0,XMM0,xmm1,XMM1,xmm2,XMM2,xmm3,XMM3,xmm4,XMM4,xmm5,XMM5,xmm6,XMM6,xmm7,XMM7,xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15!>>
+ALL_GPR textequ <!<ax,AX,cx,CX,dx,DX,bx,BX,sp,SP,bp,BP,si,SI,di,DI,r8,R8,r9,R9,r10,R10,r11,R11,r12,R12,r13,R13,r14,R14,r15,R15!>>
+REX_GPR textequ <!<r8,R8,r9,R9,r10,R10,r11,R11,r12,R12,r13,R13,r14,R14,r15,R15!>>
+DD_GPR textequ <!<eax,EAX,ecx,ECX,edx,EDX,ebx,EBX,esp,ESP,ebp,EBP,esi,ESI,edi,EDI,r8d,R8D,r9d,R9D,r10d,R10D,r11d,R11D,r12d,R12D,r13d,R13D,r14d,R14D,r15d,R15D!>>
+
+REPLACE_GPR MACRO x ; this macro substites any GPR register
+ xretxmm textequ <> ; with XMM equivalent (with the same index in mod/r/m byte)
+ gpridx = 0
+ %FOR igpr,ALL_GPR
+ IF @InStr(,x,igpr) NE 0
+ xmmidx = 0
+ %FOR ixmm,ALL_XMM
+ IF xmmidx EQ gpridx
+ xretxmm textequ <ixmm>
+ EXITM xretxmm
+ ENDIF ; if idx xmm & gpr is EQ
+ xmmidx = xmmidx + 1
+ ENDM ; for ixmm
+ IF @SizeStr(%xretxmm) GT 0
+ EXITM xretxmm
+ ENDIF
+ ENDIF
+ gpridx = gpridx + 1
+ ENDM ; for igpr
+ EXITM xretxmm ; if replacement has not been found - return empty string that will cause ASM error
+ENDM
+
+TEST_REX MACRO x:req, y:req, rex:req, bit64:req
+ rex = 0
+ %FOR igpr,REX_GPR
+ IF @InStr(,x,igpr) NE 0
+ rex = 1
+ EXITM
+ ENDIF
+ IF @InStr(,y,igpr) NE 0
+ rex = 1
+ EXITM
+ ENDIF
+ ENDM ; for igpr
+ bit64 = 1
+ %FOR igpr,DD_GPR
+ IFIDN <igpr>, <x>
+ bit64 = 0
+ EXITM
+ ENDIF
+ ENDM ; for igpr
+ENDM
+
+IFDEF ML1200
+
+OPTION NOKEYWORD:<adcx>
+OPTION NOKEYWORD:<adox>
+
+ENDIF
+
+; REX.W 66.0F38.F6/r
+adcx MACRO op1:req, op2:req
+ local x0, x1, rex
+ op1subst textequ REPLACE_GPR( op1 )
+ TEST_REX op1, op2, rex, bit64
+ rex = rex + 2
+ if bit64 GT 0
+ x0:
+ pinsrq op1subst, op2, 0
+ x1:
+ org x0 + 3
+ db 038H
+ db 0F6H
+ org x1 - 1
+ else
+ x0:
+ pinsrd op1subst, op2, 0
+ x1:
+ org x0 + rex
+ db 038H
+ db 0F6H
+ org x1 - 1
+ endif
+endm
+
+; REX.W F3.0F38.F6/r
+adox MACRO op1:req, op2:req
+ local x0, x1, rex
+ op1subst textequ REPLACE_GPR( op1 )
+ TEST_REX op1, op2, rex, bit64
+ rex = rex + 2
+ if bit64 GT 0
+ x0:
+ pinsrq op1subst, op2, 0
+ x1:
+ org x0
+ db 0F3H
+ org x0 + 3
+ db 038H
+ db 0F6H
+ org x1 - 1
+ else
+ x0:
+ pinsrd op1subst, op2, 0
+ x1:
+ org x0
+ db 0F3H
+ org x0 + rex
+ db 038H
+ db 0F6H
+ org x1 - 1
+ endif
+endm
+;ENDIF ; IFNDEF ML1200
+
+
+;IFNDEF ML1400
+IFDEF ML1400
+ OPTION NOKEYWORD:<sha1rnds4>
+ OPTION NOKEYWORD:<sha1nexte>
+ OPTION NOKEYWORD:<sha1msg1>
+ OPTION NOKEYWORD:<sha1msg2>
+ OPTION NOKEYWORD:<sha256rnds2>
+ OPTION NOKEYWORD:<sha256msg1>
+ OPTION NOKEYWORD:<sha256msg2>
+ENDIF
+
+HIGHQ_GPR textequ <!<r8,R8,r9,R9,r10,R10,r11,R11,r12,R12,r13,R13,r14,R14,r15,R15!>>
+LOWQ_GPR textequ <!<rax,RAX,rcx,RCX,rdx,RDX,rbx,RBX,rsp,RSP,rbp,RBP,rsi,RSI,rdi,RDI!>>
+HIGH_XMM textequ <!<xmm8,XMM8,xmm9,XMM9,xmm10,XMM10,xmm11,XMM11,xmm12,XMM12,xmm13,XMM13,xmm14,XMM14,xmm15,XMM15!>>
+LOW_XMM textequ <!<xmm0,XMM0,xmm1,XMM1,xmm2,XMM2,xmm3,XMM3,xmm4,XMM4,xmm5,XMM5,xmm6,XMM6,xmm7,XMM7!>>
+HIGHDQ_GPR textequ <!<R8D,r8d,R8,r8,R9D,r9d,R9,r9,R10D,r10d,R10,r10,R11D,r11d,R11,r11,R12D,r12d,R12,r12,R13D,r13d,R13,r13,R14D,r14d,R14,r14,R15D,r15d,R15,r15!>>
+LOWDQ_GPR textequ <!<EAX,eax,RAX,rax,ECX,ecx,RCX,rcx,EDX,edx,RDX,rdx,EBX,ebx,RBX,rbx,ESP,esp,RSP,rsp,EBP,ebp,RBP,rbp,ESI,esi,RSI,rsi,EDI,edi,RDI,rdi!>>
+LOWD_GPR textequ <!<eax,EAX,ecx,ECX,edx,EDX,ebx,EBX,esp,ESP,ebp,EBP,esi,ESI,edi,EDI!>>
+HIGHD_GPR textequ <!<r8d,R8D,r9d,R9D,r10d,R10D,r11d,R11D,r12d,R12D,r13d,R13D,r14d,R14D,r15d,R15D!>>
+LOWW_GPR textequ <!<ax,AX,cx,CX,dx,DX,bx,BX,sp,SP,bp,BP,si,SI,di,DI!>>
+HIGHW_GPR textequ <!<r8w,R8W,r9w,R9W,r10w,R10W,r11w,R11W,r12w,R12W,r13w,R13W,r14w,R14W,r15w,R15W!>>
+LOWB_GPR textequ <!<al,AL,cl,CL,dl,DL,bl,BL,ah,AH,ch,CH,dh,DH,bh,BH!>>
+HIGHB_GPR textequ <!<r8b,R8B,r9b,R9B,r10b,R10B,r11b,R11B,r12b,R12B,r13b,R13B,r14b,R14B,r15b,R15B,spl,SPL,bpl,BPL,sil,SIL,dil,DIL!>>
+ALL_NUM textequ <!<15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0!>>
+
+YES_REX MACRO x, REX
+ REX = 0
+ %FOR yrex,HIGH_XMM ; if xmm from 8-15 range - REX byte is required
+ IFIDN <yrex>,<x>
+ REX = 1
+ EXITM
+ ENDIF
+ ENDM
+ IF REX EQ 0
+ %FOR yrex,HIGHDQ_GPR ; if gpr from 8-15 range - REX byte is required
+ IF @InStr( , x, yrex ) NE 0
+ REX = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDIF
+ENDM
+
+CVT_GPR MACRO x ; this macro substites any gpr from the high half (8-15)
+ xretgpr textequ <x> ; with the gpr from the low half wich produces the same
+ qgpr = 0 ; index in the mod/r/m and sib bytes
+ %FOR ygpr,HIGHDQ_GPR
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ fgpr = 0
+ %FOR zgpr,LOWDQ_GPR
+ IF fgpr EQ qgpr
+ f1gpr SUBSTR <x>, 1, posgpr-1
+ f2gpr SUBSTR <x>, posgpr + @SizeStr( ygpr )
+ xretgpr CATSTR <f1gpr>, < zgpr >, <f2gpr>
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ EXITM xretgpr
+ENDM
+
+CVT_XMM MACRO x ; this macro substites any xmm from the high half (8-15)
+ xretxmm textequ <x> ; with the xmm from the low half wich produces the same
+ lxmm = 0 ; index in the mod/r/m byte
+ %FOR yxmm,HIGH_XMM
+ posxmm INSTR <x>,<yxmm>
+ IF posxmm GT 0
+ fxmm = 0
+ %FOR zxmm,LOW_XMM
+ IF fxmm EQ lxmm
+ xretxmm textequ <zxmm>
+ EXITM xretxmm
+ ENDIF ; if f == l
+ fxmm = fxmm + 1
+ ENDM ; for z
+ ENDIF ; if posx > 0
+ lxmm = lxmm + 1
+ ENDM ; for y
+ EXITM xretxmm
+ENDM
+
+CVT_HIGH MACRO x ; a wrapper for macros that substitute up-half registers
+ xs textequ CVT_GPR( x ) ; with their ia32 analogues that have the same index in
+ xs1 textequ CVT_GPR( %xs ) ; the mod/r/m byte
+ xs2 textequ CVT_XMM( %xs1 )
+ EXITM xs2
+ENDM
+
+YES_NAME MACRO x ; if "x" contains direct reference to memory operand (by
+ znam = ( OPATTR( x )) AND 0011110111y ; name defined in code or data section) 1 is returned
+ IF znam EQ 0 ; else 0
+ xnam = 1
+ ELSE
+ xnam = 0
+ ENDIF
+ EXITM %xnam
+ENDM
+
+CVT_MIMM MACRO x, y ; if "x" contains direct reference to memory operand (by
+ zimm = ( OPATTR( x )) AND 0011110111y ; name defined in code or data section) it is substituted
+ IF zimm EQ 0 ; by "y" operand in order to produce right REX byte, but
+ ximm textequ <y> ; don't produce relocation record (because current address
+ ELSE ; for relocation due to different instruction length is wrong)
+ ximm textequ <x>
+ ENDIF
+ EXITM ximm
+ENDM
+
+sha_instruction macro dst:req, src:req, nis:req, opc:req, imm8
+ local x0, x1, x2, x3, x4, x5, x6, x7
+
+ bracket INSTR <src>,<[>
+ IF bracket GT 0
+ memtype INSTR <src>,<oword>
+ IF memtype EQ 0
+ memtype INSTR <src>,<OWORD>
+ ENDIF
+ IF memtype EQ 0
+ .ERR <src must contain: oword ptr >
+ EXITM
+ ENDIF
+ ENDIF
+ bracket INSTR <dst>,<[>
+ IF bracket GT 0
+ memtype INSTR <dst>,<oword>
+ IF memtype EQ 0
+ memtype INSTR <dst>,<OWORD>
+ ENDIF
+ IF memtype EQ 0
+ .ERR <dst must contain: oword ptr >
+ EXITM
+ ENDIF
+ ENDIF
+ YES_REX <src>,REX ; do we need REX byte due to src operand?
+ REXS = REX
+ IF REXS EQ 1 ; if yes - we have to prepare substitution in order
+ s1rc textequ CVT_HIGH( src ) ; to work correctly with direct memory operands
+ ELSE
+ s1rc textequ <src> ; else substitution is not required
+ ENDIF
+ YES_REX <dst>,REX ; do we need REX byte due to dst operand?
+ REXD = REX
+ IF REXD EQ 1 ; if yes - we have to prepare substitution in order
+ d1st textequ CVT_HIGH( dst ) ; to work correctly with direct memory operands
+ ELSE
+ d1st textequ <dst> ; else substitution is not required
+ ENDIF
+ REX = REXS + REXD
+ NAMS = YES_NAME( src ) ; is there the direct memory operand (defined by name in code
+ NAMD = YES_NAME( dst ) ; or data section)? if yes - then another algorithm for macro
+ isname = NAMS + NAMD ; substitution due to bug in ml with relocations definition
+ s2rc textequ CVT_MIMM( src, xmm0 )
+ d2st textequ CVT_MIMM( dst, xmm0 )
+ IF isname GT 0 ; if src or dst contains direct reference to memory operand
+ IF REX GT 0
+ x0:
+ nop
+ nop
+ movaps d1st,s1rc ; 90 90 0F 28 /r m32
+ x1:
+ org x0
+ movaps d2st,s2rc ; REX 0F 28 /r /r m32
+ org x0+2
+ db nis
+ db opc
+ IFNB <imm8>
+ org x0+5
+ dd 0FFFFFFFFH
+ org x1 ; REX 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x1
+ ENDIF
+ ELSE
+ x2:
+ nop
+ movaps dst, src ; 90 0F 28 /r m32
+ x3:
+ org x2
+ db 0FH
+ db nis
+ db opc
+ IFNB <imm8>
+ org x2+4
+ dd 0FFFFFFFFH
+ org x3 ; 0F nis opc /r m32
+ db imm8
+ ELSE
+ org x3
+ ENDIF
+ ENDIF
+ ELSE ; if src or dst doesn't contain direct reference to memory operand
+ IF REX GT 0
+ x4:
+ movaps dst,src ; REX 0F 28 /r
+ org x4+1
+ movaps dst,src ; REX REX 0F 28 /r
+ x5:
+ org x4+1
+ db 0FH
+ db nis
+ db opc
+ org x5 ; REX 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ELSE
+ x6:
+ nop
+ movaps dst, src ; 90 0F 28 /r
+ x7:
+ org x6
+ db 0FH
+ db nis
+ db opc
+ org x7 ; 0F nis opc /r
+ IFNB <imm8>
+ db imm8
+ ENDIF
+ ENDIF
+ ENDIF
+endm
+
+; 0F 3A CC /r ib
+sha1rnds4 MACRO op1:req, op2:req, imm8:req
+ sha_instruction op1, op2, 3AH, 0CCH, imm8
+endm
+
+; 0F 38 C8 /r
+sha1nexte MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0C8H,
+endm
+
+; 0F 38 C9 /r
+sha1msg1 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0C9H,
+endm
+
+; 0F 38 CA /r
+sha1msg2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CAH,
+endm
+
+; 0F 38 CB /r <xmm0>
+sha256rnds2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CBH,
+endm
+
+; 0F 38 CC /r
+sha256msg1 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CCH,
+endm
+
+; 0F 38 CD /r
+sha256msg2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CDH,
+endm
+
+;ENDIF ;ML1400
+
+ENDIF ; MNI & SNI macro for Linux or for Windows
+
+
+IF 0
+;; The example of macro usage:
+.code
+
+my PROC NEAR PUBLIC
+ ;; The GPRs (general purpose registers) to be preserved (if used):
+ ;; rbp, rbx, rsi, rdi, r12, r13, r14, r15.
+ USES_GPR rbx, rsi, rdi, rbp, rax, r12
+ ;; Local frame must be allways set (to zero, if it is not used).
+ LOCAL_FRAME = 100
+ ;; The XMM registers to be preserved (if used):
+ ;; XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15
+ USES_XMM xmm4,xmm7,xmm11
+ ;; Number of input parameters.
+ COMP_ABI 9
+ nop
+ ;; Restore all saved XMMs.
+ REST_XMM
+ ;; Restore all saved GPRs.
+ REST_GPR
+ ret
+my ENDP
+
+END
+ENDIF
+
+CACHE_SIZE_TABLE MACRO
+TableCacheSize:
+;=========================================
+; Code: bits [7-4] - code_of_size
+; Code: bits [3-0] - shift
+; CACHE_SIZE = code_of_size << (shift + 18)
+; |Value| |Code|
+;=========================================
+db 0ech, 0c3h ; 24M 24, 64, L3 ; from doc cpuid for Nehalem
+db 0ebh, 093h ; 18M 24, 64, L3 ; from doc cpuid for Nehalem
+db 04dh, 016h ; 16M 16, 64, L3
+db 0eah, 034h ; 12M 24, 64, L3 ; from doc cpuid for Nehalem
+db 04ch, 034h ; 12M 12, 64, L3
+db 0e4h, 015h ; 8M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0deh, 015h ; 8M 12, 64, L3 ; from doc cpuid for Nehalem
+db 04bh, 015h ; 8M 16, 64, L3
+db 047h, 015h ; 8M 8, 64, L3
+db 04eh, 033h ; 6M 24, 64, L3
+db 04ah, 033h ; 6M 12, 64, L3
+db 0e3h, 014h ; 4M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0ddh, 014h ; 4M 12, 64, L3 ; from doc cpuid for Nehalem
+db 0d8h, 014h ; 4M 8, 64, L3 ; from doc cpuid for Nehalem
+db 049h, 014h ; 4M 16, 64, L3
+db 029h, 014h ; 4M 8, 64, L3
+db 046h, 014h ; 4M 4, 64, L3
+db 048h, 032h ; 3M 12, 64, L3
+db 0e2h, 013h ; 2M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0dch, 013h ; 2M 12, 64, L3 ; from doc cpuid for Nehalem
+db 0d7h, 013h ; 2M 8, 64, L3 ; from doc cpuid for Nehalem
+db 0d2h, 013h ; 2M 4, 64, L3 ; from doc cpuid for Nehalem
+db 025h, 013h ; 2M 8, 64, L3
+db 07dh, 013h ; 2M 8, 64, L2
+db 085h, 013h ; 2M 8, 32, L2
+db 045h, 013h ; 2M 4, 32, L2
+db 0d6h, 012h ; 1M 8, 64, L3 ; from doc cpuid for Nehalem
+db 0d1h, 012h ; 1M 4, 64, L3 ; from doc cpuid for Nehalem
+db 023h, 012h ; 1M 8, 64, L3
+db 087h, 012h ; 1M 8, 64, L2
+db 07ch, 012h ; 1M 8, 64, L2
+db 078h, 012h ; 1M 4, 64, L2
+db 084h, 012h ; 1M 8, 32, L2
+db 044h, 012h ; 1M 4, 32, L2
+db 0d0h, 011h ; 512K 4, 64, L3 ; from doc cpuid for Nehalem
+db 022h, 011h ; 512K 4, 64, L3
+db 07bh, 011h ; 512K 8, 64, L2
+db 080h, 011h ; 512K 8, 64, L2
+db 086h, 011h ; 512K 4, 64, L2
+db 03eh, 011h ; 512K 4, 64, L2
+db 07fh, 011h ; 512K 2, 64, L2
+db 083h, 011h ; 512K 8, 32, L2
+db 043h, 011h ; 512K 4, 32, L2
+db 0
+;=========================================
+ENDM
+
+GET_CACHE_SIZE MACRO reg:REQ
+;=========================================
+ sub rsp, 64
+ mov [rsp + 16], rax
+ mov [rsp + 24], rbx
+ mov [rsp + 32], rcx
+ mov [rsp + 40], rdx
+ mov [rsp + 48], r8
+ mov [rsp + 56], reg ; Pointers to the TableCacheSize
+
+ xor eax, eax
+ cpuid
+
+ cmp ebx, 756E6547h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp edx, 49656E69h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp ecx, 6c65746eh
+ jne CacheSizeMacro11 ; Not Intel
+
+ mov eax, 2
+ cpuid
+
+ cmp al, 1
+ jne CacheSizeMacro11
+
+ test eax, 080000000h
+ jz CacheSizeMacro00
+ xor eax, eax
+CacheSizeMacro00:
+ test ebx, 080000000h
+ jz CacheSizeMacro01
+ xor ebx, ebx
+CacheSizeMacro01:
+ test ecx, 080000000h
+ jz CacheSizeMacro02
+ xor ecx, ecx
+CacheSizeMacro02:
+ test edx, 080000000h
+ jz CacheSizeMacro03
+ xor edx, edx
+
+CacheSizeMacro03:
+ mov r8, rsp
+ test eax, eax
+ jz CacheSizeMacro04
+ mov [r8], eax
+ add r8, 4
+ mov eax, 3
+CacheSizeMacro04:
+ test ebx, ebx
+ jz CacheSizeMacro05
+ mov [r8], ebx
+ add r8, 4
+ add eax, 4
+CacheSizeMacro05:
+ test ecx, ecx
+ jz CacheSizeMacro06
+ mov [r8], ecx
+ add r8, 4
+ add eax, 4
+CacheSizeMacro06:
+ test edx, edx
+ jz CacheSizeMacro07
+ mov [r8], edx
+ add eax, 4
+
+CacheSizeMacro07:
+ mov rbx, [rsp + 56] ; rbx: Pointers to the TableCacheSize
+
+ test eax, eax
+ jz CacheSizeMacro11
+CacheSizeMacro08:
+ movzx edx, BYTE PTR [rbx]
+ test edx, edx
+ jz CacheSizeMacro11
+ add rbx, 2
+ mov ecx, eax
+CacheSizeMacro09:
+ cmp dl, BYTE PTR [rsp + rcx]
+ je CacheSizeMacro10
+ sub ecx, 1
+ jnz CacheSizeMacro09
+ jmp CacheSizeMacro08
+
+CacheSizeMacro10:
+ movzx ebx, BYTE PTR [rbx - 1]
+ mov ecx, ebx
+ shr ebx, 4
+ and ecx, 0fh
+ add ecx, 18
+ shl rbx, cl ; ebx: CacheSize
+ mov [rsp + 56], rbx
+ jmp CacheSizeMacro12
+
+CacheSizeMacro11:
+ mov QWORD PTR [rsp + 56], -1
+
+CacheSizeMacro12:
+ mov rax, [rsp + 16]
+ mov rbx, [rsp + 24]
+ mov rcx, [rsp + 32]
+ mov rdx, [rsp + 40]
+ mov r8, [rsp + 48]
+ mov reg, [rsp + 56]
+ add rsp, 64
+;=========================================
+ENDM
+
+GET_CACHE_SIZE_CORE MACRO reg:REQ
+;=========================================
+ sub rsp, 72
+ mov [rsp + 16], rax
+ mov [rsp + 24], rbx
+ mov [rsp + 32], rcx
+ mov [rsp + 40], rdx
+ mov [rsp + 48], r8
+ mov [rsp + 56], reg ; Pointers to the TableCacheSize
+
+ xor eax, eax
+ cpuid
+
+ cmp ebx, 756E6547h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp edx, 49656E69h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp ecx, 6c65746eh
+ jne CacheSizeMacro11 ; Not Intel
+
+ cmp eax, 4
+ jl CoreMacro00
+
+ mov eax, 4
+ xor ecx, ecx
+ cpuid
+ shr eax, 26
+ add eax, 1
+ mov [rsp + 64], rax ; cores
+ jmp CacheSizeMacro
+
+CoreMacro00:
+ mov QWORD PTR [rsp + 64], 1
+
+CacheSizeMacro:
+ mov eax, 2
+ cpuid
+
+ cmp al, 1
+ jne CacheSizeMacro11
+
+ test eax, 080000000h
+ jz CacheSizeMacro00
+ xor eax, eax
+CacheSizeMacro00:
+ test ebx, 080000000h
+ jz CacheSizeMacro01
+ xor ebx, ebx
+CacheSizeMacro01:
+ test ecx, 080000000h
+ jz CacheSizeMacro02
+ xor ecx, ecx
+CacheSizeMacro02:
+ test edx, 080000000h
+ jz CacheSizeMacro03
+ xor edx, edx
+
+CacheSizeMacro03:
+ mov r8, rsp
+ test eax, eax
+ jz CacheSizeMacro04
+ mov [r8], eax
+ add r8, 4
+ mov eax, 3
+CacheSizeMacro04:
+ test ebx, ebx
+ jz CacheSizeMacro05
+ mov [r8], ebx
+ add r8, 4
+ add eax, 4
+CacheSizeMacro05:
+ test ecx, ecx
+ jz CacheSizeMacro06
+ mov [r8], ecx
+ add r8, 4
+ add eax, 4
+CacheSizeMacro06:
+ test edx, edx
+ jz CacheSizeMacro07
+ mov [r8], edx
+ add eax, 4
+
+CacheSizeMacro07:
+ mov rbx, [rsp + 56] ; rbx: Pointers to the TableCacheSize
+
+ test eax, eax
+ jz CacheSizeMacro11
+CacheSizeMacro08:
+ movzx edx, BYTE PTR [rbx]
+ test edx, edx
+ jz CacheSizeMacro11
+ add rbx, 2
+ mov ecx, eax
+CacheSizeMacro09:
+ cmp dl, BYTE PTR [rsp + rcx]
+ je CacheSizeMacro10
+ sub ecx, 1
+ jnz CacheSizeMacro09
+ jmp CacheSizeMacro08
+
+CacheSizeMacro10:
+ movzx eax, BYTE PTR [rbx - 1]
+ mov ecx, eax
+ shr eax, 4
+ and ecx, 0fh
+ add ecx, 18
+ shl rax, cl ; rax: CacheSize
+ mov rcx, [rsp + 64] ; rcx: cores
+ xor edx, edx
+ div rcx
+ mov [rsp + 56], rax
+ jmp CacheSizeMacro12
+
+CacheSizeMacro11:
+ mov QWORD PTR [rsp + 56], -1
+
+CacheSizeMacro12:
+ mov rax, [rsp + 16]
+ mov rbx, [rsp + 24]
+ mov rcx, [rsp + 32]
+ mov rdx, [rsp + 40]
+ mov r8, [rsp + 48]
+ mov reg, [rsp + 56]
+ add rsp, 72
+;=========================================
+ENDM
+
+.LIST
+
diff --git a/ext/ipp/sources/include/ia_emm.inc b/ext/ipp/sources/include/ia_emm.inc
new file mode 100644
index 0000000..ffb1f52
--- /dev/null
+++ b/ext/ipp/sources/include/ia_emm.inc
@@ -0,0 +1,2966 @@
+;===============================================================================
+; Copyright 2014-2018 Intel Corporation
+; All Rights Reserved.
+;
+; If this software was obtained under the Intel Simplified Software License,
+; the following terms apply:
+;
+; The source code, information and material ("Material") contained herein is
+; owned by Intel Corporation or its suppliers or licensors, and title to such
+; Material remains with Intel Corporation or its suppliers or licensors. The
+; Material contains proprietary information of Intel or its suppliers and
+; licensors. The Material is protected by worldwide copyright laws and treaty
+; provisions. No part of the Material may be used, copied, reproduced,
+; modified, published, uploaded, posted, transmitted, distributed or disclosed
+; in any way without Intel's prior express written permission. No license under
+; any patent, copyright or other intellectual property rights in the Material
+; is granted to or conferred upon you, either expressly, by implication,
+; inducement, estoppel or otherwise. Any license under such intellectual
+; property rights must be express and approved by Intel in writing.
+;
+; Unless otherwise agreed by Intel in writing, you may not remove or alter this
+; notice or any other notice embedded in Materials by Intel or Intel's
+; suppliers or licensors in any way.
+;
+;
+; If this software was obtained under the Apache License, Version 2.0 (the
+; "License"), the following terms apply:
+;
+; You may not use this file except in compliance with the License. You may
+; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+;
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;===============================================================================
+
+; 07.06.2012 ml 11.0 support added
+
+; This macro package requires an assembler vesion 7.10 or later.
+;.NOLIST
+.LISTALL
+.686
+.XMM
+
+include asmdefs.inc
+
+MM2WORD TEXTEQU <QWORD> ; used only by the compiler, obsolete
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; beginning of the MACRO section : ;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+DEFINED MACRO symbol:REQ
+ IFDEF symbol
+ EXITM <-1>
+ ELSE
+ EXITM <0>
+ ENDIF
+ENDM
+
+
+CurVer TEXTEQU @Version
+IF @Version GT 900
+ D_ML900 equ 1
+ELSE
+ ymmword equ oword
+ENDIF
+
+IF @Version GE 1100
+ ML1100 equ 1
+ENDIF
+
+IF @Version GE 1200
+ ML1200 equ 1
+ENDIF
+
+IF @Version GE 1400
+ ML1400 equ 1
+ENDIF
+
+if 1
+CALLASM macro x:req
+ IFDEF _OWN_MERGED_BLD
+ IF _IPP EQ _IPP_PX
+ @CatStr(<call px_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_W7
+ @CatStr(<call w7_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_V8
+ @CatStr(<call v8_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_S8
+ @CatStr(<call s8_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_P8
+ @CatStr(<call p8_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_G9
+ @CatStr(<call g9_>, <x>)
+ ENDIF
+ IF _IPP EQ _IPP_H9
+ @CatStr(<call h9_>, <x>)
+ ENDIF
+ ELSE
+ @CatStr(<call >, <x>)
+ ENDIF
+endm
+endif
+
+if 1
+IPPASM macro x:req, y:VARARG
+ IFDEF _OWN_MERGED_BLD
+ IF _IPP EQ _IPP_PX
+ @CatStr(<px_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_W7
+ @CatStr(<w7_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_V8
+ @CatStr(<v8_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_S8
+ @CatStr(<s8_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_P8
+ @CatStr(<p8_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_G9
+ @CatStr(<g9_>, <x>, < y>)
+ ENDIF
+ IF _IPP EQ _IPP_H9
+ @CatStr(<h9_>, <x>, < y>)
+ ENDIF
+ ELSE
+ @CatStr(<>, <x>, < y>)
+ ENDIF
+endm
+endif
+
+IF DEFINED (OSX32) OR DEFINED (_YASM) OR DEFINED (LINUX32); MNI macro for Linux or for Windows
+
+ sha1rnds4 MACRO op1:req, op2:req, imm8:req
+ %ECHO @CatStr(<sha1rnds4 >, < op1,>, < op2,>, < imm8 >)
+ endm
+ sha1nexte MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1nexte >, < op1,>, < op2 >)
+ endm
+ sha1msg1 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1msg1 >, < op1,>, < op2 >)
+ endm
+ sha1msg2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha1msg2 >, < op1,>, < op2 >)
+ endm
+ sha256msg1 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256msg1 >, < op1,>, < op2 >)
+ endm
+ sha256msg2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256msg2 >, < op1,>, < op2 >)
+ endm
+ sha256rnds2 MACRO op1:req, op2:req
+ %ECHO @CatStr(<sha256rnds2 >, < op1,>, < op2 >)
+ endm
+
+ IFNDEF ML1200
+ adcx macro x:req, z:req
+ %ECHO @CatStr(<adcx >, < x,>, < z >)
+ endm
+ adox macro x:req, z:req
+ %ECHO @CatStr(<adox >, < x,>, < z >)
+ endm
+ENDIF; IFNDEF ML1200
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MNI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+IFNDEF ML1100
+ IFNDEF D_ML900
+
+ phaddw macro x:req, y:req
+ %ECHO @CatStr(<phaddw >, < x,>, < y >)
+ endm
+ phaddd macro x:req, y:req
+ %ECHO @CatStr(<phaddd >, < x,>, < y >)
+ endm
+ phaddsw macro x:req, y:req
+ %ECHO @CatStr(<phaddsw >, < x,>, < y >)
+ endm
+ phsubw macro x:req, y:req
+ %ECHO @CatStr(<phsubw >, < x,>, < y >)
+ endm
+ phsubd macro x:req, y:req
+ %ECHO @CatStr(<phsubd >, < x,>, < y >)
+ endm
+ phsubsw macro x:req, y:req
+ %ECHO @CatStr(<phsubsw >, < x,>, < y >)
+ endm
+ pmaddubsw macro x:req, y:req
+ %ECHO @CatStr(<pmaddubsw >, < x,>, < y >)
+ endm
+ pmulhrsw macro x:req, y:req
+ %ECHO @CatStr(<pmulhrsw >, < x,>, < y >)
+ endm
+ pshufb macro x:req, y:req
+ %ECHO @CatStr(<pshufb >, < x,>, < y >)
+ endm
+ psignb macro x:req, y:req
+ %ECHO @CatStr(<psignb >, < x,>, < y >)
+ endm
+ psignw macro x:req, y:req
+ %ECHO @CatStr(<psignw >, < x,>, < y >)
+ endm
+ psignd macro x:req, y:req
+ %ECHO @CatStr(<psignd >, < x,>, < y >)
+ endm
+ palignr macro x:req, y:req, z:req
+ %ECHO @CatStr(<palignr >, < x,>, < y,>, < z >)
+ endm
+ pabsb macro x:req, y:req
+ %ECHO @CatStr(<pabsb >, < x,>, < y >)
+ endm
+ pabsw macro x:req, y:req
+ %ECHO @CatStr(<pabsw >, < x,>, < y >)
+ endm
+ pabsd macro x:req, y:req
+ %ECHO @CatStr(<pabsd >, < x,>, < y >)
+ endm
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SNI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ blendpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<blendpd >, < x,>, < y,>, < z >)
+ endm
+ blendps macro x:req, y:req, z:req
+ %ECHO @CatStr(<blendps >, < x,>, < y,>, < z >)
+ endm
+ blendvpd macro x:req, y:req, z
+ %ECHO @CatStr(<blendvpd >, < x,>, < y>)
+ endm
+ blendvps macro x:req, y:req, z
+ %ECHO @CatStr(<blendvps >, < x,>, < y>)
+ endm
+ dppd macro x:req, y:req, z:req
+ %ECHO @CatStr(<dppd >, < x,>, < y,>, < z >)
+ endm
+ dpps macro x:req, y:req, z:req
+ %ECHO @CatStr(<dpps >, < x,>, < y,>, < z >)
+ endm
+ extractps macro x:req, y:req, z:req
+ %ECHO @CatStr(<extractps >, < x,>, < y,>, < z >)
+ endm
+ insertps macro x:req, y:req, z:req
+ %ECHO @CatStr(<insertps >, < x,>, < y,>, < z >)
+ endm
+ movntdqa macro x:req, y:req
+ %ECHO @CatStr(<movntdqa >, < x,>, < y>)
+ endm
+ mpsadbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<mpsadbw >, < x,>, < y,>, < z >)
+ endm
+ packusdw macro x:req, y:req
+ %ECHO @CatStr(<packusdw >, < x,>, < y>)
+ endm
+ pblendvb macro x:req, y:req, z
+ %ECHO @CatStr(<pblendvb >, < x,>, < y>)
+ endm
+ pblendw macro x:req, y:req, z:req
+ %ECHO @CatStr(<pblendw >, < x,>, < y,>, < z >)
+ endm
+ pcmpeqq macro x:req, y:req
+ %ECHO @CatStr(<pcmpeqq >, < x,>, < y>)
+ endm
+ pextrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrb >, < x,>, < y,>, < z >)
+ endm
+ pextrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrd >, < x,>, < y,>, < z >)
+ endm
+IF _IPP GE _IPP_P8
+ OPTION NOKEYWORD:<pextrw>
+ pextrw macro x:req, y:req, z:req
+ %ECHO @CatStr(<pextrw >, < x,>, < y,>, < z >)
+ endm
+ENDIF
+ phminposuw macro x:req, y:req
+ %ECHO @CatStr(<phminposuw >, < x,>, < y>)
+ endm
+ pinsrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<pinsrb >, < x,>, < y,>, < z >)
+ endm
+ pinsrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<pinsrd >, < x,>, < y,>, < z >)
+ endm
+ pmaxsb macro x:req, y:req
+ %ECHO @CatStr(<pmaxsb >, < x,>, < y>)
+ endm
+ pmaxsd macro x:req, y:req
+ %ECHO @CatStr(<pmaxsd >, < x,>, < y>)
+ endm
+ pmaxud macro x:req, y:req
+ %ECHO @CatStr(<pmaxud >, < x,>, < y>)
+ endm
+ pmaxuw macro x:req, y:req
+ %ECHO @CatStr(<pmaxuw >, < x,>, < y>)
+ endm
+ pminsb macro x:req, y:req
+ %ECHO @CatStr(<pminsb >, < x,>, < y>)
+ endm
+ pminsd macro x:req, y:req
+ %ECHO @CatStr(<pminsd >, < x,>, < y>)
+ endm
+ pminud macro x:req, y:req
+ %ECHO @CatStr(<pminud >, < x,>, < y>)
+ endm
+ pminuw macro x:req, y:req
+ %ECHO @CatStr(<pminuw >, < x,>, < y>)
+ endm
+ pmovsxbw macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbw >, < x,>, < y>)
+ endm
+ pmovsxbd macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbd >, < x,>, < y>)
+ endm
+ pmovsxbq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxbq >, < x,>, < y>)
+ endm
+ pmovsxwd macro x:req, y:req
+ %ECHO @CatStr(<pmovsxwd >, < x,>, < y>)
+ endm
+ pmovsxwq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxwq >, < x,>, < y>)
+ endm
+ pmovsxdq macro x:req, y:req
+ %ECHO @CatStr(<pmovsxdq >, < x,>, < y>)
+ endm
+ pmovzxbw macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbw >, < x,>, < y>)
+ endm
+ pmovzxbd macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbd >, < x,>, < y>)
+ endm
+ pmovzxbq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxbq >, < x,>, < y>)
+ endm
+ pmovzxwd macro x:req, y:req
+ %ECHO @CatStr(<pmovzxwd >, < x,>, < y>)
+ endm
+ pmovzxwq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxwq >, < x,>, < y>)
+ endm
+ pmovzxdq macro x:req, y:req
+ %ECHO @CatStr(<pmovzxdq >, < x,>, < y>)
+ endm
+ pmuldq macro x:req, y:req
+ %ECHO @CatStr(<pmuldq >, < x,>, < y>)
+ endm
+ pmulld macro x:req, y:req
+ %ECHO @CatStr(<pmulld >, < x,>, < y>)
+ endm
+ ptest macro x:req, y:req
+ %ECHO @CatStr(<ptest >, < x,>, < y>)
+ endm
+ roundpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundpd >, < x,>, < y,>, < z >)
+ endm
+ roundps macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundps >, < x,>, < y,>, < z >)
+ endm
+ roundsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundsd >, < x,>, < y,>, < z >)
+ endm
+ roundss macro x:req, y:req, z:req
+ %ECHO @CatStr(<roundss >, < x,>, < y,>, < z >)
+ endm
+; SSE4.2
+ pcmpestri macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpestri >, < x,>, < y,>, < z >)
+ endm
+ pcmpestrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpestrm >, < x,>, < y,>, < z >)
+ endm
+ pcmpistri macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpistri >, < x,>, < y,>, < z >)
+ endm
+ pcmpistrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<pcmpistrm >, < x,>, < y,>, < z >)
+ endm
+ pcmpgtq macro x:req, y:req
+ %ECHO @CatStr(<pcmpgtq >, < x,>, < y>)
+ endm
+ crc32 macro x:req, y:req
+ %ECHO @CatStr(<crc32 >, < x,>, < y>)
+ endm
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WSM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+aesenc macro x:req, y:req
+ %ECHO @CatStr(<aesenc >, < x,>, < y>)
+ endm
+aesenclast macro x:req, y:req
+ %ECHO @CatStr(<aesenclast >, < x,>, < y>)
+ endm
+aesdec macro x:req, y:req
+ %ECHO @CatStr(<aesdec >, < x,>, < y>)
+ endm
+aesdeclast macro x:req, y:req
+ %ECHO @CatStr(<aesdeclast >, < x,>, < y>)
+ endm
+aesimc macro x:req, y:req
+ %ECHO @CatStr(<aesimc >, < x,>, < y>)
+ endm
+aeskeygenassist macro x:req, y:req, z:req
+ %ECHO @CatStr(<aeskeygenassist >, < x,>, < y,>, < z >)
+ endm
+pclmulqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<pclmulqdq >, < x,>, < y,>, < z >)
+ endm
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AVX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+vaesenc macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesenc >, < x,>, < y,>, < z >)
+ endm
+vaesenclast macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesenclast >, < x,>, < y,>, < z >)
+ endm
+vaesdec macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesdec >, < x,>, < y,>, < z >)
+ endm
+vaesdeclast macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaesdeclast >, < x,>, < y,>, < z >)
+ endm
+vaesimc macro x:req, y:req
+ %ECHO @CatStr(<vaesimc >, < x,>, < y>)
+ endm
+vaeskeygenassist macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaeskeygenassist >, < x,>, < y,>, < z >)
+ endm
+vaddpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddpd >, < x,>, < y,>, < z >)
+ endm
+vaddps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddps >, < x,>, < y,>, < z >)
+ endm
+vaddsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsd >, < x,>, < y,>, < z >)
+ endm
+vaddss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddss >, < x,>, < y,>, < z >)
+ endm
+vaddsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsubpd >, < x,>, < y,>, < z >)
+ endm
+vaddsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vaddsubps >, < x,>, < y,>, < z >)
+ endm
+vandpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandpd >, < x,>, < y,>, < z >)
+ endm
+vandps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandps >, < x,>, < y,>, < z >)
+ endm
+vandnpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandnpd >, < x,>, < y,>, < z >)
+ endm
+vandnps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vandnps >, < x,>, < y,>, < z >)
+ endm
+vblendpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendvpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendvpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vblendvps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vblendvps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vbroadcastss macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastss >, < x,>, < y>)
+ endm
+vbroadcastsd macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastsd >, < x,>, < y>)
+ endm
+vbroadcastf128 macro x:req, y:req
+ %ECHO @CatStr(<vbroadcastf128 >, < x,>, < y>)
+ endm
+vcmpeqpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqpd >, < x,>, < y,>, < z >)
+ endm
+vcmpltpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltpd >, < x,>, < y,>, < z >)
+ endm
+vcmplepd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmplepd >, < x,>, < y,>, < z >)
+ endm
+vcmpunordpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordpd >, < x,>, < y,>, < z >)
+ endm
+vcmpneqpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqpd >, < x,>, < y,>, < z >)
+ endm
+vcmpnltpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltpd >, < x,>, < y,>, < z >)
+ endm
+vcmpnlepd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnlepd >, < x,>, < y,>, < z >)
+ endm
+vcmpordpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordpd >, < x,>, < y,>, < z >)
+ endm
+vcmppd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmppd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpsd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpsd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpeqps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqps >, < x,>, < y,>, < z >)
+ endm
+vcmpltps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltps >, < x,>, < y,>, < z >)
+ endm
+vcmpleps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpleps >, < x,>, < y,>, < z >)
+ endm
+vcmpunordps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordps >, < x,>, < y,>, < z >)
+ endm
+vcmpneqps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqps >, < x,>, < y,>, < z >)
+ endm
+vcmpnltps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltps >, < x,>, < y,>, < z >)
+ endm
+vcmpnleps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnleps >, < x,>, < y,>, < z >)
+ endm
+vcmpordps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordps >, < x,>, < y,>, < z >)
+ endm
+vcmpeqsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqsd >, < x,>, < y,>, < z >)
+ endm
+vcmpltsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltsd >, < x,>, < y,>, < z >)
+ endm
+vcmplesd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmplesd >, < x,>, < y,>, < z >)
+ endm
+vcmpunordsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordsd >, < x,>, < y,>, < z >)
+ endm
+vcmpneqsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqsd >, < x,>, < y,>, < z >)
+ endm
+vcmpnltsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltsd >, < x,>, < y,>, < z >)
+ endm
+vcmpnlesd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnlesd >, < x,>, < y,>, < z >)
+ endm
+vcmpordsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordsd >, < x,>, < y,>, < z >)
+ endm
+vcmpss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vcmpss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vcmpeqss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpeqss >, < x,>, < y,>, < z >)
+ endm
+vcmpltss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpltss >, < x,>, < y,>, < z >)
+ endm
+vcmpless macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpless >, < x,>, < y,>, < z >)
+ endm
+vcmpunordss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpunordss >, < x,>, < y,>, < z >)
+ endm
+vcmpneqss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpneqss >, < x,>, < y,>, < z >)
+ endm
+vcmpnltss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnltss >, < x,>, < y,>, < z >)
+ endm
+vcmpnless macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpnless >, < x,>, < y,>, < z >)
+ endm
+vcmpordss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcmpordss >, < x,>, < y,>, < z >)
+ endm
+vcomisd macro x:req, y:req
+ %ECHO @CatStr(<vcomisd >, < x,>, < y>)
+ endm
+vcomiss macro x:req, y:req
+ %ECHO @CatStr(<vcomiss >, < x,>, < y>)
+ endm
+vcvtdq2pd macro x:req, y:req
+ %ECHO @CatStr(<vcvtdq2pd >, < x,>, < y>)
+ endm
+vcvtdq2ps macro x:req, y:req
+ %ECHO @CatStr(<vcvtdq2ps >, < x,>, < y>)
+ endm
+vcvtpd2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvtpd2dq >, < x,>, < y>)
+ endm
+vcvtpd2ps macro x:req, y:req
+ %ECHO @CatStr(<vcvtpd2ps >, < x,>, < y>)
+ endm
+vcvtps2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvtps2dq >, < x,>, < y>)
+ endm
+vcvtps2pd macro x:req, y:req
+ %ECHO @CatStr(<vcvtps2pd >, < x,>, < y>)
+ endm
+vcvtsd2si macro x:req, y:req
+ %ECHO @CatStr(<vcvtsd2si >, < x,>, < y>)
+ endm
+vcvtsd2ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsd2ss >, < x,>, < y,>, < z>)
+ endm
+vcvtsi2sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsi2sd >, < x,>, < y,>, < z>)
+ endm
+vcvtsi2ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtsi2ss >, < x,>, < y,>, < z>)
+ endm
+vcvtss2sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vcvtss2sd >, < x,>, < y,>, < z>)
+ endm
+vcvtss2si macro x:req, y:req
+ %ECHO @CatStr(<vcvtss2si >, < x,>, < y>)
+ endm
+vcvttpd2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvttpd2dq >, < x,>, < y>)
+ endm
+vcvttps2dq macro x:req, y:req
+ %ECHO @CatStr(<vcvttps2dq >, < x,>, < y>)
+ endm
+vcvttsd2si macro x:req, y:req
+ %ECHO @CatStr(<vcvttsd2si >, < x,>, < y>)
+ endm
+vcvttss2si macro x:req, y:req
+ %ECHO @CatStr(<vcvttss2si >, < x,>, < y>)
+ endm
+vdivpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivpd >, < x,>, < y,>, < z >)
+ endm
+vdivps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivps >, < x,>, < y,>, < z >)
+ endm
+vdivsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivsd >, < x,>, < y,>, < z >)
+ endm
+vdivss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vdivss >, < x,>, < y,>, < z >)
+ endm
+vdppd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vdppd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vdpps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vdpps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vextractf128 macro x:req, y:req, z:req
+ %ECHO @CatStr(<vextractf128 >, < x,>, < y,>, < z >)
+ endm
+vextractps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vextractps >, < x,>, < y,>, < z >)
+ endm
+vhaddpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhaddpd >, < x,>, < y,>, < z >)
+ endm
+vhaddps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhaddps >, < x,>, < y,>, < z >)
+ endm
+vhsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhsubpd >, < x,>, < y,>, < z >)
+ endm
+vhsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vhsubps >, < x,>, < y,>, < z >)
+ endm
+vinsertf128 macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vinsertf128 >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vinsertps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vinsertps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vlddqu macro x:req, y:req
+ %ECHO @CatStr(<vlddqu >, < x,>, < y>)
+ endm
+vldmxcsr macro x:req
+ %ECHO @CatStr(<vldmxcsr >, < x>)
+ endm
+vmaskmovdqu macro x:req, y:req
+ %ECHO @CatStr(<vmaskmovdqu >, < x,>, < y>)
+ endm
+vmaskmovpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaskmovpd >, < x,>, < y,>, < z >)
+ endm
+vmaskmovps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaskmovps >, < x,>, < y,>, < z >)
+ endm
+vmaxpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxpd >, < x,>, < y,>, < z >)
+ endm
+vmaxps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxps >, < x,>, < y,>, < z >)
+ endm
+vmaxsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxsd >, < x,>, < y,>, < z >)
+ endm
+vmaxss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmaxss >, < x,>, < y,>, < z >)
+ endm
+vminpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminpd >, < x,>, < y,>, < z >)
+ endm
+vminps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminps >, < x,>, < y,>, < z >)
+ endm
+vminsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminsd >, < x,>, < y,>, < z >)
+ endm
+vminss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vminss >, < x,>, < y,>, < z >)
+ endm
+vmovapd macro x:req, y:req
+ %ECHO @CatStr(<vmovapd >, < x,>, < y>)
+ endm
+vmovaps macro x:req, y:req
+ %ECHO @CatStr(<vmovaps >, < x,>, < y>)
+ endm
+vmovd macro x:req, y:req
+ %ECHO @CatStr(<vmovd >, < x,>, < y>)
+ endm
+vmovddup macro x:req, y:req
+ %ECHO @CatStr(<vmovddup >, < x,>, < y>)
+ endm
+vmovdqa macro x:req, y:req
+ %ECHO @CatStr(<vmovdqa >, < x,>, < y>)
+ endm
+vmovdqu macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovdqu >, < x,>, < y>)
+ endm
+vmovhlps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovhlps >, < x,>, < y,>, < z>)
+ endm
+vmovhpd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovhpd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovhpd >, < x,>, < y>)
+ ENDIF
+endm
+vmovhps macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovhps >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovhps >, < x,>, < y>)
+ ENDIF
+endm
+vmovlhps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmovlhps >, < x,>, < y,>, < z>)
+ endm
+vmovlpd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovlpd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovlpd >, < x,>, < y>)
+ ENDIF
+endm
+vmovlps macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovlps >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovlps >, < x,>, < y>)
+ ENDIF
+endm
+vmovmskpd macro x:req, y:req
+ %ECHO @CatStr(<vmovmskpd >, < x,>, < y>)
+ endm
+vmovmskps macro x:req, y:req
+ %ECHO @CatStr(<vmovmskps >, < x,>, < y>)
+ endm
+vmovntdq macro x:req, y:req
+ %ECHO @CatStr(<vmovntdq >, < x,>, < y>)
+ endm
+vmovntdqa macro x:req, y:req
+ %ECHO @CatStr(<vmovntdqa >, < x,>, < y>)
+ endm
+vmovntpd macro x:req, y:req
+ %ECHO @CatStr(<vmovntpd >, < x,>, < y>)
+ endm
+vmovntps macro x:req, y:req
+ %ECHO @CatStr(<vmovntps >, < x,>, < y>)
+ endm
+vmovntq macro x:req, y:req
+ %ECHO @CatStr(<vmovntq >, < x,>, < y>)
+ endm
+vmovq macro x:req, y:req
+ %ECHO @CatStr(<vmovq >, < x,>, < y>)
+ endm
+vmovsd macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovsd >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovsd >, < x,>, < y>)
+ ENDIF
+endm
+vmovshdup macro x:req, y:req
+ %ECHO @CatStr(<vmovshdup >, < x,>, < y>)
+ endm
+vmovsldup macro x:req, y:req
+ %ECHO @CatStr(<vmovsldup >, < x,>, < y>)
+ endm
+vmovss macro x:req, y:req, z
+ IFNB <z>
+ %ECHO @CatStr(<vmovss >, < x,>, < y,>, < z>)
+ ELSE
+ %ECHO @CatStr(<vmovss >, < x,>, < y>)
+ ENDIF
+endm
+vmovupd macro x:req, y:req
+ %ECHO @CatStr(<vmovupd >, < x,>, < y>)
+ endm
+vmovups macro x:req, y:req
+ %ECHO @CatStr(<vmovups >, < x,>, < y>)
+ endm
+vmpsadbw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vmpsadbw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vmulpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulpd >, < x,>, < y,>, < z >)
+ endm
+vmulps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulps >, < x,>, < y,>, < z >)
+ endm
+vmulsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulsd >, < x,>, < y,>, < z >)
+ endm
+vmulss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vmulss >, < x,>, < y,>, < z >)
+ endm
+vorpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vorpd >, < x,>, < y,>, < z >)
+ endm
+vorps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vorps >, < x,>, < y,>, < z >)
+ endm
+vpabsb macro x:req, y:req
+ %ECHO @CatStr(<vpabsb >, < x,>, < y>)
+ endm
+vpabsw macro x:req, y:req
+ %ECHO @CatStr(<vpabsw >, < x,>, < y>)
+ endm
+vpabsd macro x:req, y:req
+ %ECHO @CatStr(<vpabsd >, < x,>, < y>)
+ endm
+vpackssdw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackssdw >, < x,>, < y,>, < z >)
+ endm
+vpacksswb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpacksswb >, < x,>, < y,>, < z >)
+ endm
+vpackuswb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackuswb >, < x,>, < y,>, < z >)
+ endm
+vpackusdw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpackusdw >, < x,>, < y,>, < z >)
+ endm
+vpaddb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddb >, < x,>, < y,>, < z >)
+ endm
+vpaddd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddd >, < x,>, < y,>, < z >)
+ endm
+vpaddq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddq >, < x,>, < y,>, < z >)
+ endm
+vpaddsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddsb >, < x,>, < y,>, < z >)
+ endm
+vpaddsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddsw >, < x,>, < y,>, < z >)
+ endm
+vpaddusb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddusb >, < x,>, < y,>, < z >)
+ endm
+vpaddusw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddusw >, < x,>, < y,>, < z >)
+ endm
+vpaddw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpaddw >, < x,>, < y,>, < z >)
+ endm
+vpand macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpand >, < x,>, < y,>, < z >)
+ endm
+vpandn macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpandn >, < x,>, < y,>, < z >)
+ endm
+vpavgb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpavgb >, < x,>, < y,>, < z >)
+ endm
+vpavgw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpavgw >, < x,>, < y,>, < z >)
+ endm
+vpalignr macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpalignr >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpblendvb macro x:req, y:req, z:req, q:req
+ %ECHO @CatStr(<vpblendvb >, < x,>, < y,>, < z,>, < q>)
+ endm
+vpblendw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpblendw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpclmulqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpclmulqdq >, < x,>, < y,>, < z >)
+ endm
+vpcmpestri macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpestri >, < x,>, < y,>, < z >)
+ endm
+vpcmpestrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpestrm >, < x,>, < y,>, < z >)
+ endm
+vpcmpistri macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpistri >, < x,>, < y,>, < z >)
+ endm
+vpcmpistrm macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpistrm >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqb >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqd >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqw >, < x,>, < y,>, < z >)
+ endm
+vpcmpeqq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpeqq >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtb >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtd >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtw >, < x,>, < y,>, < z >)
+ endm
+vpcmpgtq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpcmpgtq >, < x,>, < y,>, < z >)
+ endm
+vpermilpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermilpd >, < x,>, < y,>, < z >)
+ endm
+vpermil2pd macro x:req, y:req, z:req, v:req, imm:req
+ %ECHO @CatStr(<vpermil2pd >, < x,>, < y,>, < z,>, < v,>, < imm>)
+ endm
+vpermilps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpermilps >, < x,>, < y,>, < z >)
+ endm
+vpermil2ps macro x:req, y:req, z:req, v:req, imm:req
+ %ECHO @CatStr(<vpermil2ps >, < x,>, < y,>, < z,>, < v,>, < imm>)
+ endm
+vperm2f128 macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vperm2f128 >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpextrb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrb >, < x,>, < y,>, < z >)
+ endm
+vpextrd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrd >, < x,>, < y,>, < z >)
+ endm
+vpextrq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrq >, < x,>, < y,>, < z >)
+ endm
+vpextrw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpextrw >, < x,>, < y,>, < z >)
+ endm
+vphaddw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddw >, < x,>, < y,>, < z >)
+ endm
+vphaddd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddd >, < x,>, < y,>, < z >)
+ endm
+vphaddsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphaddsw >, < x,>, < y,>, < z >)
+ endm
+vphminposuw macro x:req, y:req
+ %ECHO @CatStr(<vphminposuw >, < x,>, < y>)
+ endm
+vphsubw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubw >, < x,>, < y,>, < z >)
+ endm
+vphsubd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubd >, < x,>, < y,>, < z >)
+ endm
+vphsubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vphsubsw >, < x,>, < y,>, < z >)
+ endm
+vpinsrb macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrb >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrq macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrq >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpinsrw macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vpinsrw >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vpmaddwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaddwd >, < x,>, < y,>, < z >)
+ endm
+vpmaddubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaddubsw >, < x,>, < y,>, < z >)
+ endm
+vpmaxsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsb >, < x,>, < y,>, < z >)
+ endm
+vpmaxsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsd >, < x,>, < y,>, < z >)
+ endm
+vpmaxsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxsw >, < x,>, < y,>, < z >)
+ endm
+vpmaxub macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxub >, < x,>, < y,>, < z >)
+ endm
+vpmaxud macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxud >, < x,>, < y,>, < z >)
+ endm
+vpmaxuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmaxuw >, < x,>, < y,>, < z >)
+ endm
+vpminsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsb >, < x,>, < y,>, < z >)
+ endm
+vpminsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsd >, < x,>, < y,>, < z >)
+ endm
+vpminsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminsw >, < x,>, < y,>, < z >)
+ endm
+vpminub macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminub >, < x,>, < y,>, < z >)
+ endm
+vpminud macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminud >, < x,>, < y,>, < z >)
+ endm
+vpminuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpminuw >, < x,>, < y,>, < z >)
+ endm
+vpmovmskb macro x:req, y:req
+ %ECHO @CatStr(<vpmovmskb >, < x,>, < y>)
+ endm
+vpmovsxbw macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbw >, < x,>, < y>)
+ endm
+vpmovsxbd macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbd >, < x,>, < y>)
+ endm
+vpmovsxbq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxbq >, < x,>, < y>)
+ endm
+vpmovsxwd macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxwd >, < x,>, < y>)
+ endm
+vpmovsxwq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxwq >, < x,>, < y>)
+ endm
+vpmovsxdq macro x:req, y:req
+ %ECHO @CatStr(<vpmovsxdq >, < x,>, < y>)
+ endm
+vpmovzxbw macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbw >, < x,>, < y>)
+ endm
+vpmovzxbd macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbd >, < x,>, < y>)
+ endm
+vpmovzxbq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxbq >, < x,>, < y>)
+ endm
+vpmovzxwd macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxwd >, < x,>, < y>)
+ endm
+vpmovzxwq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxwq >, < x,>, < y>)
+ endm
+vpmovzxdq macro x:req, y:req
+ %ECHO @CatStr(<vpmovzxdq >, < x,>, < y>)
+ endm
+vpmulhuw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhuw >, < x,>, < y,>, < z >)
+ endm
+vpmulhrsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhrsw >, < x,>, < y,>, < z >)
+ endm
+vpmulhw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulhw >, < x,>, < y,>, < z >)
+ endm
+vpmullw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmullw >, < x,>, < y,>, < z >)
+ endm
+vpmulld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmulld >, < x,>, < y,>, < z >)
+ endm
+vpmuludq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmuludq >, < x,>, < y,>, < z >)
+ endm
+vpmuldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpmuldq >, < x,>, < y,>, < z >)
+ endm
+vpor macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpor >, < x,>, < y,>, < z >)
+ endm
+vpsadbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsadbw >, < x,>, < y,>, < z >)
+ endm
+vpshufb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufb >, < x,>, < y,>, < z >)
+ endm
+vpshufd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufd >, < x,>, < y,>, < z >)
+ endm
+vpshufhw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshufhw >, < x,>, < y,>, < z >)
+ endm
+vpshuflw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpshuflw >, < x,>, < y,>, < z >)
+ endm
+vpsignb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignb >, < x,>, < y,>, < z >)
+ endm
+vpsignw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignw >, < x,>, < y,>, < z >)
+ endm
+vpsignd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsignd >, < x,>, < y,>, < z >)
+ endm
+vpslld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpslld >, < x,>, < y,>, < z >)
+ endm
+vpslldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpslldq >, < x,>, < y,>, < z >)
+ endm
+vpsllq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllq >, < x,>, < y,>, < z >)
+ endm
+vpsllw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsllw >, < x,>, < y,>, < z >)
+ endm
+vpsrad macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrad >, < x,>, < y,>, < z >)
+ endm
+vpsraw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsraw >, < x,>, < y,>, < z >)
+ endm
+vpsrld macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrld >, < x,>, < y,>, < z >)
+ endm
+vpsrldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrldq >, < x,>, < y,>, < z >)
+ endm
+vpsrlq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlq >, < x,>, < y,>, < z >)
+ endm
+vpsrlw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsrlw >, < x,>, < y,>, < z >)
+ endm
+vptest macro x:req, y:req
+ %ECHO @CatStr(<vptest >, < x,>, < y>)
+ endm
+vpsubb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubb >, < x,>, < y,>, < z >)
+ endm
+vpsubd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubd >, < x,>, < y,>, < z >)
+ endm
+vpsubq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubq >, < x,>, < y,>, < z >)
+ endm
+vpsubsb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubsb >, < x,>, < y,>, < z >)
+ endm
+vpsubsw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubsw >, < x,>, < y,>, < z >)
+ endm
+vpsubusb macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubusb >, < x,>, < y,>, < z >)
+ endm
+vpsubusw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubusw >, < x,>, < y,>, < z >)
+ endm
+vpsubw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpsubw >, < x,>, < y,>, < z >)
+ endm
+vpunpckhbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhbw >, < x,>, < y,>, < z >)
+ endm
+vpunpckhdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhdq >, < x,>, < y,>, < z >)
+ endm
+vpunpckhqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhqdq >, < x,>, < y,>, < z >)
+ endm
+vpunpckhwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckhwd >, < x,>, < y,>, < z >)
+ endm
+vpunpcklbw macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklbw >, < x,>, < y,>, < z >)
+ endm
+vpunpckldq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpckldq >, < x,>, < y,>, < z >)
+ endm
+vpunpcklqdq macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklqdq >, < x,>, < y,>, < z >)
+ endm
+vpunpcklwd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpunpcklwd >, < x,>, < y,>, < z >)
+ endm
+vpxor macro x:req, y:req, z:req
+ %ECHO @CatStr(<vpxor >, < x,>, < y,>, < z >)
+ endm
+vrcpps macro x:req, y:req
+ %ECHO @CatStr(<vrcpps >, < x,>, < y>)
+ endm
+vrcpss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vrcpss >, < x,>, < y>)
+ endm
+vrsqrtps macro x:req, y:req
+ %ECHO @CatStr(<vrsqrtps >, < x,>, < y>)
+ endm
+vrsqrtss macro x:req, y:req
+ %ECHO @CatStr(<vrsqrtss >, < x,>, < y>)
+ endm
+vroundpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vroundpd >, < x,>, < y,>, < z >)
+ endm
+vroundps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vroundps >, < x,>, < y,>, < z >)
+ endm
+vroundsd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vroundsd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vroundss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vroundss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vshufpd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vshufpd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vshufps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vshufps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vsqrtpd macro x:req, y:req
+ %ECHO @CatStr(<vsqrtpd >, < x,>, < y>)
+ endm
+vsqrtps macro x:req, y:req
+ %ECHO @CatStr(<vsqrtps >, < x,>, < y>)
+ endm
+vsqrtsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsqrtsd >, < x,>, < y,>, < z >)
+ endm
+vsqrtss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsqrtss >, < x,>, < y,>, < z >)
+ endm
+vstmxcsr macro x:req
+ %ECHO @CatStr(<vstmxcsr >, < x>)
+ endm
+vsubpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubpd >, < x,>, < y,>, < z >)
+ endm
+vsubps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubps >, < x,>, < y,>, < z >)
+ endm
+vsubsd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubsd >, < x,>, < y,>, < z >)
+ endm
+vsubss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vsubss >, < x,>, < y,>, < z >)
+ endm
+vucomisd macro x:req, y:req
+ %ECHO @CatStr(<vucomisd >, < x,>, < y>)
+ endm
+vucomiss macro x:req, y:req
+ %ECHO @CatStr(<vucomiss >, < x,>, < y>)
+ endm
+vunpckhpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpckhpd >, < x,>, < y,>, < z >)
+ endm
+vunpckhps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpckhps >, < x,>, < y,>, < z >)
+ endm
+vunpcklpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpcklpd >, < x,>, < y,>, < z >)
+ endm
+vunpcklps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vunpcklps >, < x,>, < y,>, < z >)
+ endm
+vxorpd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vxorpd >, < x,>, < y,>, < z >)
+ endm
+vxorps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vxorps >, < x,>, < y,>, < z >)
+ endm
+vzeroall macro
+ %ECHO @CatStr(<vzeroall>)
+ endm
+vzeroupper macro
+ %ECHO @CatStr(<vzeroupper>)
+ endm
+vfmadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfmadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfmadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231pd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231pd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfmadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfmadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231ps macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231ps >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132sd >, < x,>, < y,>, < z >)
+ endm
+vfmadd213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213sd >, < x,>, < y,>, < z >)
+ endm
+vfmadd231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231sd >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231sd macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231sd >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmadd132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd132ss >, < x,>, < y,>, < z >)
+ endm
+vfmadd213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd213ss >, < x,>, < y,>, < z >)
+ endm
+vfmadd231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmadd231ss >, < x,>, < y,>, < z >)
+ endm
+vfmaddrnd231ss macro x:req, y:req, z:req, imm:req
+ %ECHO @CatStr(<vfmaddrnd231ss >, < x,>, < y,>, < z,>, < imm>)
+ endm
+vfmaddsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfmaddsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmaddsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfmsubadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsubadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfmsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfmsub132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231sd >, < x,>, < y,>, < z >)
+ endm
+vfmsub132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub132ss >, < x,>, < y,>, < z >)
+ endm
+vfmsub213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub213ss >, < x,>, < y,>, < z >)
+ endm
+vfmsub231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfmsub231ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231pd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231ps >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231sd >, < x,>, < y,>, < z >)
+ endm
+vfnmadd132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd132ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd213ss >, < x,>, < y,>, < z >)
+ endm
+vfnmadd231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmadd231ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231pd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231pd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231ps macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231ps >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231sd macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231sd >, < x,>, < y,>, < z >)
+ endm
+vfnmsub132ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub132ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub213ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub213ss >, < x,>, < y,>, < z >)
+ endm
+vfnmsub231ss macro x:req, y:req, z:req
+ %ECHO @CatStr(<vfnmsub231ss >, < x,>, < y,>, < z >)
+ endm
+ ELSE
+ OPTION NOKEYWORD:<blendvpd>
+ blendvpd macro x:req, y:req, z
+ %ECHO @CatStr(<blendvpd >, < x,>, < y>)
+ endm
+ OPTION NOKEYWORD:<blendvps>
+ blendvps macro x:req, y:req, z
+ %ECHO @CatStr(<blendvps >, < x,>, < y>)
+ endm
+ OPTION NOKEYWORD:<pblendvb>
+ pblendvb macro x:req, y:req, z
+ %ECHO @CatStr(<pblendvb >, < x,>, < y>)
+ endm
+ ENDIF ; IF D_ML900 GT 0
+ ENDIF ; IFNDEF ML1100
+ELSE ; if not OSX or Linux - so all below is for Windows
+ IFNDEF ML1200
+
+ ENDIF ; IFNDEF ML1200
+ IFNDEF ML1100
+ ; MNI (TNI)
+
+ nis_mni = 38h ;new instruction set
+ nis_mnia = 3Ah ;new instruction set 'a'
+ reg_mmx = 0Fh ;media registers type
+ reg_xmm = 66h ;media registers type
+
+ opc_phaddw = 01h
+ opc_phaddd = 02h
+ opc_phaddsw = 03h
+ opc_phsubw = 05h
+ opc_phsubd = 06h
+ opc_phsubsw = 07h
+ opc_pmaddubsw = 04h
+ opc_pmulhrsw = 0Bh
+ opc_pshufb = 00h
+ opc_psignb = 08h
+ opc_psignw = 09h
+ opc_psignd = 0Ah
+ opc_palignr = 0Fh
+ opc_pabsb = 1Ch
+ opc_pabsw = 1Dh
+ opc_pabsd = 1Eh
+
+ IFMMX_REG MACRO x, f
+ f = 0
+ FOR y,<mm0,MM0,mm1,MM1,mm2,MM2,mm3,MM3,mm4,MM4,mm5,MM5,mm6,MM6,mm7,MM7>
+ IFIDN <y>,<x>
+ f = 1
+ EXITM
+ ENDIF
+ ENDM
+ ENDM
+
+ mni_instruction macro dst:req, src:req, nis:req, opc:req
+ local x, y
+ IFMMX_REG <dst>,f
+ IF f GT 0
+ db reg_mmx
+ x:
+ pand dst, src
+ y:
+ org x
+ db nis
+ db opc
+ org y
+ ELSE
+ db reg_xmm
+ x:
+ pand dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis
+ db opc
+ org y
+ ENDIF
+ endm
+
+ ;IF @Version LT 900
+ IFNDEF D_ML900
+
+ ; OPTION NOKEYWORD:<phaddw>
+ ; 66 0F 38 01 /r phaddw xmm1, xmm2/m128
+ ; 0F 38 01 /r phaddw mm1, mm2/m64
+ phaddw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phaddw
+ endm
+
+ ; OPTION NOKEYWORD:<phaddd>
+ ; 0F 38 02 /r phaddd mm1, mm2/m64
+ ; 66 0F 38 02 /r phaddd xmm1, xmm2/m128
+ phaddd macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phaddd
+ endm
+
+ ; OPTION NOKEYWORD:<phaddsw>
+ ; 0F 38 03 /r phaddsw mm1, mm2/m64
+ ; 66 0F 38 03 /r phaddsw xmm1, xmm2/m128
+ phaddsw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phaddsw
+ endm
+
+ ; OPTION NOKEYWORD:<phsubw>
+ ; 0F 38 05 /r phsubw mm1, mm2/m64
+ ; 66 0F 38 05 /r phsubw xmm1, xmm2/m128
+ phsubw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phsubw
+ endm
+
+ ; OPTION NOKEYWORD:<phsubd>
+ ; 0F 38 06 /r phsubd mm1, mm2/m64
+ ; 66 0F 38 06 /r phsubd xmm1, xmm2/m128
+ phsubd macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phsubd
+ endm
+
+ ; OPTION NOKEYWORD:<phsubsw>
+ ; 0F 38 07 /r phsubsw mm1, mm2/m64
+ ; 66 0F 38 07 /r phsubsw xmm1, xmm2/m128
+ phsubsw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_phsubsw
+ endm
+
+ ; OPTION NOKEYWORD:<pmaddubsw>
+ ; 0F 38 04 /r pmaddubsw mm1, mm2/m64
+ ; 66 0F 38 04 /r pmaddubsw xmm1, xmm2/m128
+ pmaddubsw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pmaddubsw
+ endm
+
+ ; OPTION NOKEYWORD:<pmulhrsw>
+ ; 0F 38 0B /r pmulhrsw mm1, mm2/m64
+ ; 66 0F 38 0B /r pmulhrsw xmm1, xmm2/m128
+ pmulhrsw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pmulhrsw
+ endm
+
+ ; OPTION NOKEYWORD:<pshufb>
+ ; 0F 38 00 /r pshufb mm1, mm2/m64
+ ; 66 0F 38 00 /r pshufb xmm1, xmm2/m128
+ pshufb macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pshufb
+ endm
+
+ ; OPTION NOKEYWORD:<psignb>
+ ; 0F 38 08 /r psignb mm1, mm2/m64
+ ; 66 0F 38 08 /r psignb xmm1, xmm2/m128
+ psignb macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_psignb
+ endm
+
+ ; OPTION NOKEYWORD:<psignw>
+ ; 0F 38 09 /r psignw mm1, mm2/m64
+ ; 66 0F 38 09 /r psignw xmm1, xmm2/m128
+ psignw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_psignw
+ endm
+
+ ; OPTION NOKEYWORD:<psignd>
+ ; 0F 38 0A /r psignd mm1, mm2/m64
+ ; 66 0F 38 0A /r psignd xmm1, xmm2/m128
+ psignd macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_psignd
+ endm
+
+ ; OPTION NOKEYWORD:<palignr>
+ ; 0F 3A 0F /r palignr mm1, mm2/m64
+ ; 66 0F 3A 0F /r palignr xmm1, xmm2/m128
+ palignr macro dst:req, src:req, imm8:req
+ mni_instruction dst, src, nis_mnia, opc_palignr
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<pabsb>
+ ; 0F 38 1C /r pabsb mm1, mm2/m64
+ ; 66 0F 38 1C /r pabsb xmm1, xmm2/m128
+ pabsb macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pabsb
+ endm
+
+ ; OPTION NOKEYWORD:<pabsw>
+ ; 0F 38 1D /r pabsw mm1, mm2/m64
+ ; 66 0F 38 1D /r pabsw xmm1, xmm2/m128
+ pabsw macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pabsw
+ endm
+
+ ; OPTION NOKEYWORD:<pabsd>
+ ; 0F 38 1E /r pabsd mm1, mm2/m64
+ ; 66 0F 38 1E /r pabsd xmm1, xmm2/m128
+ pabsd macro dst:req, src:req
+ mni_instruction dst, src, nis_mni, opc_pabsd
+ endm
+
+ ENDIF
+
+ ; SNI (Swing new instructions or SSE4)
+
+ nis_sni = 38h ; new instruction set
+ nis_snia = 3Ah ; new instruction set 'a' (with imm8)
+
+ opc_blendpd = 0Dh
+ opc_blendps = 0Ch
+ opc_blendvpd = 15h
+ opc_blendvps = 14h
+ opc_dppd = 41h
+ opc_dpps = 40h
+ opc_extractps = 17h
+ opc_insertps = 21h
+ opc_movntdqa = 2Ah
+ opc_mpsadbw = 42h
+ opc_pblendvb = 10h
+ opc_pblendw = 0Eh
+ opc_pcmpeqq = 29h
+ opc_pextrb = 14h
+ opc_pextrd = 16h
+ opc_pextrw = 15h
+ opc_phminposuw = 41h
+ opc_packusdw = 2Bh
+ opc_pinsrb = 20h
+ opc_pinsrd = 22h
+ opc_pmaxsb = 3Ch
+ opc_pmaxsd = 3Dh
+ opc_pmaxud = 3Fh
+ opc_pmaxuw = 3Eh
+ opc_pminsb = 38h
+ opc_pminsd = 39h
+ opc_pminud = 3Bh
+ opc_pminuw = 3Ah
+ opc_pmovsxbw = 20h
+ opc_pmovsxbd = 21h
+ opc_pmovsxbq = 22h
+ opc_pmovsxwd = 23h
+ opc_pmovsxwq = 24h
+ opc_pmovsxdq = 25h
+ opc_pmovzxbw = 30h
+ opc_pmovzxbd = 31h
+ opc_pmovzxbq = 32h
+ opc_pmovzxwd = 33h
+ opc_pmovzxwq = 34h
+ opc_pmovzxdq = 35h
+ opc_pmuldq = 28h
+ opc_pmulld = 40h
+ opc_ptest = 17h
+ opc_roundpd = 09h
+ opc_roundps = 08h
+ opc_roundsd = 0Bh
+ opc_roundss = 0Ah
+
+ sni_instruction macro dst:req, src:req, nis:req, opc:req
+ local x, y
+ db reg_xmm
+ x:
+ pand dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis
+ db opc
+ org y
+ endm
+
+ sni_instr_src_m64 macro dst:req, src:req, nis:req, opc:req
+ local x, y
+ db reg_xmm
+ x:
+ movsd dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis
+ db opc
+ org y
+ endm
+
+ sni_instr_src_m32 macro dst:req, src:req, nis:req, opc:req
+ local x, y
+ db reg_xmm
+ x:
+ movss dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis
+ db opc
+ org y
+ endm
+
+ SUBST_DWORD MACRO x
+ LOCAL posx, f1, f2, xret
+ xret textequ <x>
+ FOR y,<byte,Byte,BYTE,word,Word,WORD,qword,Qword,QWORD>
+ posx INSTR <x>,<y>
+ IF posx GT 0
+ f1 SUBSTR <x>, 1, posx-1
+ f2 SUBSTR <x>, posx + @SizeStr( y )
+ xret CATSTR <f1>, < dword >, <f2>
+ EXITM xret
+ ENDIF
+ ENDM
+ EXITM <xret>
+ ENDM
+
+ sni_instr_src_m16 macro dst:req, src:req, nis:req, opc:req
+ local x, y, tmpsrc
+ tmpsrc textequ SUBST_DWORD( src )
+ db reg_xmm
+ x:
+ movss dst, tmpsrc
+ y:
+ org x
+ db reg_mmx
+ db nis
+ db opc
+ org y
+ endm
+
+ ;IF @Version lt 900
+ IFNDEF D_ML900
+
+ ; OPTION NOKEYWORD:<blendpd>
+ ; 66 0F 3A 0D blendpd xmm1, xmm2/m128, imm8
+ blendpd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_blendpd
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<blendps>
+ ; 66 0F 3A 0C blendps xmm1, xmm2/m128, imm8
+ blendps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_blendps
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<blendvpd>
+ ; 66 0F 38 15 blendvpd xmm1, xmm2/m128, XMM0
+ blendvpd macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_blendvpd
+ endm
+
+ ; OPTION NOKEYWORD:<blendvps>
+ ; 66 0F 38 14 blendvps xmm1, xmm2/m128, XMM0
+ blendvps macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_blendvps
+ endm
+
+ ; OPTION NOKEYWORD:<dppd>
+ ; 66 0F 3A 41 dppd xmm1, xmm2/m128, imm8
+ dppd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_dppd
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<dpps>
+ ; 66 0F 3A 40 dpps xmm1, xmm2/m128, imm8
+ dpps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_dpps
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<extractps>
+ ; 66 0F 3A 17 extractps r/m32, xmm2, imm8
+ extractps macro dst:req, src:req, imm8:req
+ ; %sni_instruction dst, src, nis_snia, opc_extractps
+ local x, y
+ db reg_xmm
+ x:
+ movd dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis_snia
+ db opc_extractps
+ org y
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<insertps>
+ ; 66 0F 3A 21 insertps xmm1, xmm2/m32, imm8
+ insertps macro dst:req, src:req, imm8:req
+ %sni_instr_src_m32 dst, src, nis_snia, opc_insertps
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<movntdqa>
+ ; 66 0F 38 2A movntdqa xmm1, m128
+ movntdqa macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_movntdqa
+ endm
+
+ ; OPTION NOKEYWORD:<mpsadbw>
+ ; 66 0F 3A 42 mpsadbw xmm1, xmm2/m32, imm8
+ mpsadbw macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_mpsadbw
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<packusdw>
+ ; 66 0F 38 2B packusdw xmm1, xmm2/m128
+ packusdw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_packusdw
+ endm
+
+ ; OPTION NOKEYWORD:<pblendvb>
+ ; 66 0F 38 10 pblendvb xmm1, xmm2/m128, XMM0
+ pblendvb macro dst:req, src:req, z
+ %sni_instruction dst, src, nis_sni, opc_pblendvb
+ endm
+
+ ; OPTION NOKEYWORD:<pblendw>
+ ; 66 0F 3A 0E pblendw xmm1, xmm2/m128, imm8
+ pblendw macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_pblendw
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<pcmpeqq>
+ ; 66 0F 38 29 pcmpeqq xmm1, xmm2/m128
+ pcmpeqq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pcmpeqq
+ endm
+
+ ALL_MMX textequ <!<mm0,MM0,mm1,MM1,mm2,MM2,mm3,MM3,mm4,MM4,mm5,MM5,mm6,MM6,mm7,MM7!>>
+ ALL_GPR textequ <!<eax,EAX,ecx,ECX,edx,EDX,ebx,EBX,esp,ESP,ebp,EBP,esi,ESI,edi,EDI!>>
+
+ REPLACE_MMX MACRO x ; this macro substites any mmx register (in order to use mov r32,r32 instr)
+ xretgpr textequ <x> ; with the gpr equivalent (with the same index in mod/r/m byte) for pextrX instr
+ qgpr = 0
+ %FOR ygpr,ALL_MMX
+ posgpr INSTR <x>,<ygpr>
+ IF posgpr GT 0
+ fgpr = 0
+ %FOR zgpr,ALL_GPR
+ IF fgpr EQ qgpr
+ xretgpr textequ <zgpr>
+ EXITM xretgpr
+ ENDIF ; if f == q
+ fgpr = fgpr + 1
+ ENDM ; for z
+ ENDIF ; if posx > 0
+ qgpr = qgpr + 1
+ ENDM ; for y
+ EXITM xretgpr
+ ENDM
+
+ ; OPTION NOKEYWORD:<pextrb>
+ ; 66 0F 3A 14 pextrb r32/m8, xmm2, imm8
+ pextrb macro dst:req, src:req, imm8:req
+ local x, y, dstop
+ dstop textequ SUBST_DWORD( dst )
+ db reg_xmm
+ x:
+ movd dstop, src
+ y:
+ org x
+ db reg_mmx
+ db nis_snia
+ db opc_pextrb
+ org y
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<pextrd>
+ ; 66 0F 3A 16 pextrd r32/m32, xmm2, imm8
+ pextrd macro dst:req, src:req, imm8:req
+ local x, y, dstop
+ db reg_xmm
+ x:
+ movd dst, src
+ y:
+ org x
+ db reg_mmx
+ db nis_snia
+ db opc_pextrd
+ org y
+ db imm8
+ endm
+
+ ENDIF
+
+ ;IF @Version lt 900
+ IFNDEF D_ML900
+ IF _IPP GE _IPP_P8
+ OPTION NOKEYWORD:<pextrw>
+
+ ; 66 0F 3A 15 pextrw r32/m16, xmm2, imm8
+ pextrw macro dst:req, src:req, imm8:req
+ local x, y, x1, y1
+ IFMMX_REG src, f ; NO MEMORY as DESTINATION!
+ IF f GT 0
+ s2rc textequ REPLACE_MMX( src ) ; substite source mmx register with gpr that has the same index in mod/r/m byte
+ x:
+ nop
+ mov dst, s2rc ; 90 8B /r
+ y:
+ org x
+ db 0Fh
+ db 0C5h ; 0F C5 /r
+ org y
+ db imm8 ; 0F C5 /r imm8
+ ELSE
+ db reg_xmm
+ x1:
+ pinsrw src, dst, imm8 ; 66 66 0F C4 /r ib
+ y1:
+ org x1
+ db 0Fh
+ db 3Ah
+ db 15h
+ org y1 ; 66 0F 3A 15 /r ib
+ ENDIF
+ endm
+ ENDIF ; if _IPP GE _IPP_P8
+ ENDIF ; ifndef D_ML900
+
+ ;IF @Version lt 900
+ IFNDEF D_ML900
+
+ ; OPTION NOKEYWORD:<phminposuw>
+ ; 66 0F 38 41 phminposuw xmm1, xmm2/m128
+ phminposuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_phminposuw
+ endm
+
+ IFMEM_INS MACRO x
+ LOCAL posx, f1, f2, xret
+ xret textequ <x>
+ FOR y,<byte,Byte,BYTE,dword,Dword,DWORD,qword,Qword,QWORD>
+ posx INSTR <x>,<y>
+ IF posx GT 0
+ f1 SUBSTR <x>, 1, posx-1
+ f2 SUBSTR <x>, posx + @SizeStr( y )
+ xret CATSTR <f1>, < word >, <f2>
+ EXITM xret
+ ENDIF
+ ENDM
+ EXITM <xret>
+ ENDM
+
+ ; OPTION NOKEYWORD:<pinsrb>
+ ; 66 0F 3A 20 pinsrb xmm1, r32/m8, imm8
+ pinsrb macro dst:req, src:req, imm8:req
+ local x, y, srcop
+ srcop textequ IFMEM_INS( src )
+ db reg_xmm
+ x:
+ pinsrw dst, srcop, imm8
+ y:
+ org x
+ db reg_mmx
+ db nis_snia
+ db opc_pinsrb
+ org y
+ endm
+
+ ; OPTION NOKEYWORD:<pinsrd>
+ ; 66 0F 3A 22 pinsrd xmm1, r32/m32, imm8
+ pinsrd macro dst:req, src:req, imm8:req
+ local x, y, srcop
+ srcop textequ IFMEM_INS( src )
+ db reg_xmm
+ x:
+ pinsrw dst, srcop, imm8
+ y:
+ org x
+ db reg_mmx
+ db nis_snia
+ db opc_pinsrd
+ org y
+ endm
+
+ ; OPTION NOKEYWORD:<pmaxsb>
+ ; 66 0F 38 3C pmaxsb xmm1, xmm2/m128
+ pmaxsb macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxsb
+ endm
+
+ ; OPTION NOKEYWORD:<pmaxsd>
+ ; 66 0F 38 3D pmaxsd xmm1, xmm2/m128
+ pmaxsd macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxsd
+ endm
+
+ ; OPTION NOKEYWORD:<pmaxud>
+ ; 66 0F 38 3F pmaxud xmm1, xmm2/m128
+ pmaxud macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxud
+ endm
+
+ ; OPTION NOKEYWORD:<pmaxuw>
+ ; 66 0F 38 3E pmaxuw xmm1, xmm2/m128
+ pmaxuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmaxuw
+ endm
+
+ ; OPTION NOKEYWORD:<pminsb>
+ ; 66 0F 38 38 pminsb xmm1, xmm2/m128
+ pminsb macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminsb
+ endm
+
+ ; OPTION NOKEYWORD:<pminsd>
+ ; 66 0F 38 39 pminsd xmm1, xmm2/m128
+ pminsd macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminsd
+ endm
+
+ ; OPTION NOKEYWORD:<pminud>
+ ; 66 0F 38 3B pminud xmm1, xmm2/m128
+ pminud macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminud
+ endm
+
+ ; OPTION NOKEYWORD:<pminuw>
+ ; 66 0F 38 3A pminuw xmm1, xmm2/m128
+ pminuw macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pminuw
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxbw>
+ ; 66 0F 38 20 pmovsxbw xmm1, xmm2/m64
+ pmovsxbw macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovsxbw
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxbd>
+ ; 66 0F 38 21 pmovsxbd xmm1, xmm2/m32
+ pmovsxbd macro dst:req, src:req
+ %sni_instr_src_m32 dst, src, nis_sni, opc_pmovsxbd
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxbq>
+ ; 66 0F 38 22 pmovsxbq xmm1, xmm2/m16
+ pmovsxbq macro dst:req, src:req
+ %sni_instr_src_m16 dst, src, nis_sni, opc_pmovsxbq
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxwd>
+ ; 66 0F 38 23 pmovsxwd xmm1, xmm2/m64
+ pmovsxwd macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovsxwd
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxwq>
+ ; 66 0F 38 24 pmovsxwq xmm1, xmm2/m32
+ pmovsxwq macro dst:req, src:req
+ %sni_instr_src_m32 dst, src, nis_sni, opc_pmovsxwq
+ endm
+
+ ; OPTION NOKEYWORD:<pmovsxdq>
+ ; 66 0F 38 25 pmovsxdq xmm1, xmm2/m64
+ pmovsxdq macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovsxdq
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxbw>
+ ; 66 0F 38 30 pmovzxbw xmm1, xmm2/m64
+ pmovzxbw macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovzxbw
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxbd>
+ ; 66 0F 38 31 pmovzxbd xmm1, xmm2/m32
+ pmovzxbd macro dst:req, src:req
+ %sni_instr_src_m32 dst, src, nis_sni, opc_pmovzxbd
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxbq>
+ ; 66 0F 38 32 pmovzxbq xmm1, xmm2/m16
+ pmovzxbq macro dst:req, src:req
+ %sni_instr_src_m16 dst, src, nis_sni, opc_pmovzxbq
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxwd>
+ ; 66 0F 38 33 pmovzxwd xmm1, xmm2/m64
+ pmovzxwd macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovzxwd
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxwq>
+ ; 66 0F 38 34 pmovzxwq xmm1, xmm2/m32
+ pmovzxwq macro dst:req, src:req
+ %sni_instr_src_m32 dst, src, nis_sni, opc_pmovzxwq
+ endm
+
+ ; OPTION NOKEYWORD:<pmovzxdq>
+ ; 66 0F 38 35 pmovzxdq xmm1, xmm2/m64
+ pmovzxdq macro dst:req, src:req
+ %sni_instr_src_m64 dst, src, nis_sni, opc_pmovzxdq
+ endm
+
+ ; OPTION NOKEYWORD:<pmuldq>
+ ; 66 0F 38 28 pmuldq xmm1, xmm2/m128
+ pmuldq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmuldq
+ endm
+
+ ; OPTION NOKEYWORD:<pmulld>
+ ; 66 0F 38 40 pmulld xmm1, xmm2/m128
+ pmulld macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_pmulld
+ endm
+
+ ; OPTION NOKEYWORD:<ptest>
+ ; 66 0F 38 17 ptest xmm1, xmm2/m128
+ ptest macro dst:req, src:req
+ %sni_instruction dst, src, nis_sni, opc_ptest
+ endm
+
+ ; OPTION NOKEYWORD:<roundpd>
+ ; 66 0F 3A 09 roundpd xmm1, xmm2/m128, imm8
+ roundpd macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_roundpd
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<roundps>
+ ; 66 0F 3A 08 roundps xmm1, xmm2/m128, imm8
+ roundps macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_snia, opc_roundps
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<roundsd>
+ ; 66 0F 3A 0B roundsd xmm1, xmm2/m64, imm8
+ roundsd macro dst:req, src:req, imm8:req
+ %sni_instr_src_m64 dst, src, nis_snia, opc_roundsd
+ db imm8
+ endm
+
+ ; OPTION NOKEYWORD:<roundss>
+ ; 66 0F 3A 0A roundss xmm1, xmm2/m32, imm8
+ roundss macro dst:req, src:req, imm8:req
+ %sni_instr_src_m32 dst, src, nis_snia, opc_roundss
+ db imm8
+ endm
+
+ nis_sttni = 38h ; new instruction set
+ nis_sttnia = 3Ah ; new instruction set 'a' (with imm8)
+
+ opc_pcmpestri = 61h
+ opc_pcmpestrm = 60h
+ opc_pcmpistri = 63h
+ opc_pcmpistrm = 62h
+ opc_pcmpgtq = 37h
+ opc_crc32_m8 = 0F0h
+ opc_crc32 = 0F1h
+
+ ; 66 0F 3A 61 pcmpestri xmm1, xmm2/m128, imm8
+ pcmpestri macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpestri
+ db imm8
+ endm
+
+ ; 66 0F 3A 60 pcmpestrm xmm1, xmm2/m128, imm8
+ pcmpestrm macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpestrm
+ db imm8
+ endm
+
+ ; 66 0F 3A 63 pcmpistri xmm1, xmm2/m128, imm8
+ pcmpistri macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpistri
+ db imm8
+ endm
+
+ ; 66 0F 3A 62 pcmpistrm xmm1, xmm2/m128, imm8
+ pcmpistrm macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pcmpistrm
+ db imm8
+ endm
+
+ ; 66 0F 38 37 pcmpgtq xmm1, xmm2/m128
+ pcmpgtq macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_pcmpgtq
+ endm
+
+ ; WSM (AES NI)
+
+ opc_aesenc = 0DCh
+ opc_aesenclast = 0DDh
+ opc_aesdec = 0DEh
+ opc_aesdeclast = 0DFh
+ opc_aesimc = 0DBh
+ opc_aeskeygenassist = 0DFh
+ opc_pclmulqdq = 044h
+
+ ; 66 0F 38 DC aesenc xmm1, xmm2/m128
+ aesenc macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesenc
+ endm
+
+ ; 66 0F 38 DD aesenclast xmm1, xmm2/m128
+ aesenclast macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesenclast
+ endm
+
+ ; 66 0F 38 DE aesdec xmm1, xmm2/m128
+ aesdec macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesdec
+ endm
+
+ ; 66 0F 38 DF aesdeclast xmm1, xmm2/m128
+ aesdeclast macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesdeclast
+ endm
+
+ ; 66 0F 38 DB aesimc xmm1, xmm2/m128
+ aesimc macro dst:req, src:req
+ %sni_instruction dst, src, nis_sttni, opc_aesimc
+ endm
+
+ ; 66 0F 3A DF aeskeygenassist xmm1, xmm2/m128, imm8
+ aeskeygenassist macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_aeskeygenassist
+ db imm8
+ endm
+
+ ; 66 0F 3A 44 pclmulqdq xmm1, xmm2/m128, imm8
+ pclmulqdq macro dst:req, src:req, imm8:req
+ %sni_instruction dst, src, nis_sttnia, opc_pclmulqdq
+ db imm8
+ endm
+
+ ENDIF ; IFNDEF ML1100
+
+ IFNDEF ML1200
+
+ ENDIF ; IFNDEF ML1200
+
+
+IF @InStr(1,%CurVer,<710>) EQ 1
+
+; PNI for old ml versions
+
+opc_Addsubpd = 0D0H
+opc_Addsubps = 0D0H
+opc_Haddpd = 07CH
+opc_Haddps = 07CH
+opc_Hsubpd = 07DH
+opc_Hsubps = 07DH
+opc_Lddqu = 0F0H
+opc_Monitor = 0C8H
+opc_Movddup = 012H
+opc_Movshdup = 016H
+opc_Movsldup = 012H
+opc_Mwait = 0C9H
+
+
+MMWORD TEXTEQU <QWORD> ; used only by the compiler, obsolete
+XMMWORD TEXTEQU <OWORD> ; 128 bit memory operands for xmm regs inst
+
+; 66 0F C2 /r 0 cmpeqpd xmm1, xmm2
+cmpeqpd macro dst:req, src:req
+ cmppd dst, src, 0
+endm
+
+; 66 0F C2 /r 1 cmpltpd xmm1, xmm2
+cmpltpd macro dst:req, src:req
+ cmppd dst, src, 1
+endm
+
+; 66 0F C2 /r 2 cmplepd xmm1, xmm2
+cmplepd macro dst:req, src:req
+ cmppd dst, src, 2
+endm
+
+; 66 0F C2 /r 3 cmpunordpd xmm1, xmm2
+cmpunordpd macro dst:req, src:req
+ cmppd dst, src, 3
+endm
+
+; 66 0F C2 /r 4 cmpneqpd xmm1, xmm2
+cmpneqpd macro dst:req, src:req
+ cmppd dst, src, 4
+endm
+
+; 66 0F C2 /r 5 cmpltpd xmm1, xmm2
+cmpnltpd macro dst:req, src:req
+ cmppd dst, src, 5
+endm
+
+; 66 0F C2 /r 6 cmpnlepd xmm1, xmm2
+cmpnlepd macro dst:req, src:req
+ cmppd dst, src, 6
+endm
+
+; 66 0F C2 /r 7 cmpordpd xmm1, xmm2
+cmpordpd macro dst:req, src:req
+ cmppd dst, src, 7
+endm
+
+;F2 0F C2 /r 0 cmpeqsd xmm1, xmm2
+cmpeqsd macro dst:req, src:req
+ cmpsd1 dst, src, 0
+endm
+
+;F2 0F C2 /r 1 cmpltsd xmm1, xmm2
+cmpltsd macro dst:req, src:req
+ cmpsd1 dst, src, 1
+endm
+
+;F2 0F C2 /r 2 cmplesd xmm1, xmm2
+cmplesd macro dst:req, src:req
+ cmpsd1 dst, src, 2
+endm
+
+;F2 0F C2 /r 3 cmpunordsd xmm1, xmm2
+cmpunordsd macro dst:req, src:req
+ cmpsd1 dst, src, 3
+endm
+
+;F2 0F C2 /r 4 cmpneqsd xmm1, xmm2
+cmpneqsd macro dst:req, src:req
+ cmpsd1 dst, src, 4
+endm
+
+;F2 0F C2 /r 5 cmpnltsd xmm1, xmm2
+cmpnltsd macro dst:req, src:req
+ cmpsd1 dst, src, 5
+endm
+
+;F2 0F C2 /r 6 cmpnlesd xmm1, xmm2
+cmpnlesd macro dst:req, src:req
+ cmpsd1 dst, src, 6
+endm
+
+;F2 0F C2 /r 7 cmpordsd xmm1, xmm2
+cmpordsd macro dst:req, src:req
+ cmpsd1 dst, src, 7
+endm
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PNI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+ ;;66 0F D0 /r addsubpd xmm1, xmm2/m128
+ addsubpd macro dst:req, src:req
+ local x, y
+ x:
+ addpd dst, src
+ y:
+ org x+2
+ db opc_Addsubpd
+ org y
+ endm
+
+ ;;F2 0F D0 /r addsubps xmm1, xmm2/m128
+ addsubps macro dst:req, src:req
+ local x, y
+ db 0F2h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Addsubps
+ org y
+ endm
+
+ ;;66 0F 7C /r haddpd xmm1, xmm2/m128
+ haddpd macro dst:req, src:req
+ local x, y
+ x:
+ addpd dst, src
+ y:
+ org x+2
+ db opc_Haddpd
+ org y
+ endm
+
+ ;;F2 0F 7C /r haddps xmm1, xmm2/m128
+ haddps macro dst:req, src:req
+ local x, y
+ db 0F2h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Haddps
+ org y
+ endm
+
+ ;;66 0F 7D /r hsubpd xmm1, xmm2/m128
+ hsubpd macro dst:req, src:req
+ local x, y
+ x:
+ addpd dst, src
+ y:
+ org x+2
+ db opc_Hsubpd
+ org y
+ endm
+
+ ;;F2 0F 7D /r hsubps xmm1, xmm2/m128
+ hsubps macro dst:req, src:req
+ local x, y
+ db 0F2h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Hsubps
+ org y
+ endm
+
+ ;;F2 0F F0 /r lddqu xmm1, m128
+ lddqu macro dst:req, src:req
+ local x, y
+ db 0F2h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Lddqu
+ org y
+ endm
+
+ ;;F2 0F 12 /r movddup xmm1, xmm2/m128
+ movddup macro dst:req, src:req
+ local x, y
+ db 0F2h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Movddup
+ org y
+ endm
+
+ ;;F3 0F 16 /r movshdup xmm1, xmm2/m128
+ movshdup macro dst:req, src:req
+ local x, y
+ db 0F3h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Movshdup
+ org y
+ endm
+
+ ;;F3 0F 12 /r movsldup xmm1, xmm2/m128
+ movsldup macro dst:req, src:req
+ local x, y
+ db 0F3h
+ x:
+ addps dst, src
+ y:
+ org x+1
+ db opc_Movsldup
+ org y
+ endm
+
+ ;;0F 01 C8 monitor
+ monitor macro
+ db 0Fh, 01h, 0C8h
+ endm
+
+ ;;0F 01 C9 mwait
+ mwait macro
+ db 0Fh, 01h, 0C9h
+ endm
+ENDIF
+ ENDIF ; IFNDEF ML1100
+
+IFDEF ML1200
+ OPTION NOKEYWORD:<adox>
+ OPTION NOKEYWORD:<adcx>
+ENDIF
+
+ ;;66 0F 38 F6 /r adcx
+ adcx macro op1:req, op2:req
+ local x1, x2
+ db 66h
+ db 0Fh
+ x1:
+ bsf op1, op2
+ x2:
+ org x1
+ db 38H
+ db 0F6H
+ org x2
+ endm
+
+ ;;66 0F 38 F6 /r adcx
+ adox macro op1:req, op2:req
+ local x1, x2
+ db F3h
+ db 0Fh
+ x1:
+ bsf op1, op2
+ x2:
+ org x1
+ db 38H
+ db 0F6H
+ org x2
+ endm
+
+;ENDIF ; IFNDEF ML1200
+
+IFDEF ML1400
+ OPTION NOKEYWORD:<sha1rnds4>
+ OPTION NOKEYWORD:<sha1nexte>
+ OPTION NOKEYWORD:<sha1msg1>
+ OPTION NOKEYWORD:<sha1msg2>
+ OPTION NOKEYWORD:<sha256rnds2>
+ OPTION NOKEYWORD:<sha256msg1>
+ OPTION NOKEYWORD:<sha256msg2>
+ENDIF
+;IFNDEF ML1400
+
+sha_instruction macro dst:req, src:req, nis:req, opc:req, imm8
+ local x0, x1
+ db 0FH
+ x0:
+ movaps dst, src ; 0F 0F 28 /r m32
+ x1:
+ org x0
+ db nis
+ db opc
+ org x1
+ IFNB <imm8>
+ db imm8
+ ENDIF
+endm
+
+; 0F 3A CC /r ib
+sha1rnds4 MACRO op1:req, op2:req, imm8:req
+ sha_instruction op1, op2, 3AH, 0CCH, imm8
+endm
+
+; 0F 38 C8 /r
+sha1nexte MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0C8H,
+endm
+
+; 0F 38 C9 /r
+sha1msg1 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0C9H,
+endm
+
+; 0F 38 CA /r
+sha1msg2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CAH,
+endm
+
+; 0F 38 CB /r <xmm0>
+sha256rnds2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CBH,
+endm
+
+; 0F 38 CC /r
+sha256msg1 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CCH,
+endm
+
+; 0F 38 CD /r
+sha256msg2 MACRO op1:req, op2:req
+ sha_instruction op1, op2, 38H, 0CDH,
+endm
+
+;ENDIF ; IFNDEF ML1400
+
+ENDIF ; macro for Windows
+
+CACHE_SIZE_TABLE MACRO
+TableCacheSize:
+;=========================================
+; Code: bits [7-4] - code_of_size
+; Code: bits [3-0] - shift
+; CACHE_SIZE = code_of_size << (shift + 18)
+; |Value| |Code|
+;=========================================
+db 0ech, 0c3h ; 24M 24, 64, L3 ; from doc cpuid for Nehalem
+db 0ebh, 093h ; 18M 24, 64, L3 ; from doc cpuid for Nehalem
+db 04dh, 016h ; 16M 16, 64, L3
+db 0eah, 034h ; 12M 24, 64, L3 ; from doc cpuid for Nehalem
+db 04ch, 034h ; 12M 12, 64, L3
+db 0e4h, 015h ; 8M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0deh, 015h ; 8M 12, 64, L3 ; from doc cpuid for Nehalem
+db 04bh, 015h ; 8M 16, 64, L3
+db 047h, 015h ; 8M 8, 64, L3
+db 04eh, 033h ; 6M 24, 64, L3
+db 04ah, 033h ; 6M 12, 64, L3
+db 0e3h, 014h ; 4M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0ddh, 014h ; 4M 12, 64, L3 ; from doc cpuid for Nehalem
+db 0d8h, 014h ; 4M 8, 64, L3 ; from doc cpuid for Nehalem
+db 049h, 014h ; 4M 16, 64, L3
+db 029h, 014h ; 4M 8, 64, L3
+db 046h, 014h ; 4M 4, 64, L3
+db 048h, 032h ; 3M 12, 64, L3
+db 0e2h, 013h ; 2M 16, 64, L3 ; from doc cpuid for Nehalem
+db 0dch, 013h ; 2M 12, 64, L3 ; from doc cpuid for Nehalem
+db 0d7h, 013h ; 2M 8, 64, L3 ; from doc cpuid for Nehalem
+db 0d2h, 013h ; 2M 4, 64, L3 ; from doc cpuid for Nehalem
+db 025h, 013h ; 2M 8, 64, L3
+db 07dh, 013h ; 2M 8, 64, L2
+db 085h, 013h ; 2M 8, 32, L2
+db 045h, 013h ; 2M 4, 32, L2
+db 0d6h, 012h ; 1M 8, 64, L3 ; from doc cpuid for Nehalem
+db 0d1h, 012h ; 1M 4, 64, L3 ; from doc cpuid for Nehalem
+db 023h, 012h ; 1M 8, 64, L3
+db 087h, 012h ; 1M 8, 64, L2
+db 07ch, 012h ; 1M 8, 64, L2
+db 078h, 012h ; 1M 4, 64, L2
+db 084h, 012h ; 1M 8, 32, L2
+db 044h, 012h ; 1M 4, 32, L2
+db 0d0h, 011h ; 512K 4, 64, L3 ; from doc cpuid for Nehalem
+db 022h, 011h ; 512K 4, 64, L3
+db 07bh, 011h ; 512K 8, 64, L2
+db 080h, 011h ; 512K 8, 64, L2
+db 086h, 011h ; 512K 4, 64, L2
+db 03eh, 011h ; 512K 4, 64, L2
+db 07fh, 011h ; 512K 2, 64, L2
+db 083h, 011h ; 512K 8, 32, L2
+db 043h, 011h ; 512K 4, 32, L2
+db 0
+;=========================================
+ENDM
+
+GET_CACHE_SIZE MACRO reg:REQ
+;=========================================
+ sub esp, 40
+ mov [esp + 16], eax
+ mov [esp + 20], ebx
+ mov [esp + 24], ecx
+ mov [esp + 28], edx
+ mov [esp + 32], ebp
+ mov [esp + 36], reg ; Pointers to the TableCacheSize
+
+ xor eax, eax
+ cpuid
+
+ cmp ebx, 756E6547h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp edx, 49656E69h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp ecx, 6c65746eh
+ jne CacheSizeMacro11 ; Not Intel
+
+ mov eax, 2
+ cpuid
+
+ cmp al, 1
+ jne CacheSizeMacro11
+
+ test eax, 080000000h
+ jz CacheSizeMacro00
+ xor eax, eax
+CacheSizeMacro00:
+ test ebx, 080000000h
+ jz CacheSizeMacro01
+ xor ebx, ebx
+CacheSizeMacro01:
+ test ecx, 080000000h
+ jz CacheSizeMacro02
+ xor ecx, ecx
+CacheSizeMacro02:
+ test edx, 080000000h
+ jz CacheSizeMacro03
+ xor edx, edx
+
+CacheSizeMacro03:
+ mov ebp, esp
+ test eax, eax
+ jz CacheSizeMacro04
+ mov [ebp], eax
+ add ebp, 4
+ mov eax, 3
+CacheSizeMacro04:
+ test ebx, ebx
+ jz CacheSizeMacro05
+ mov [ebp], ebx
+ add ebp, 4
+ add eax, 4
+CacheSizeMacro05:
+ test ecx, ecx
+ jz CacheSizeMacro06
+ mov [ebp], ecx
+ add ebp, 4
+ add eax, 4
+CacheSizeMacro06:
+ test edx, edx
+ jz CacheSizeMacro07
+ mov [ebp], edx
+ add eax, 4
+
+CacheSizeMacro07:
+ mov ebx, [esp + 36] ; ebx: Pointers to the TableCacheSize
+
+ test eax, eax
+ jz CacheSizeMacro11
+CacheSizeMacro08:
+ movzx edx, BYTE PTR [ebx]
+ test edx, edx
+ jz CacheSizeMacro11
+ add ebx, 2
+ mov ecx, eax
+CacheSizeMacro09:
+ cmp dl, BYTE PTR [esp + ecx]
+ je CacheSizeMacro10
+ sub ecx, 1
+ jnz CacheSizeMacro09
+ jmp CacheSizeMacro08
+
+CacheSizeMacro10:
+ movzx ebx, BYTE PTR [ebx - 1]
+ mov ecx, ebx
+ shr ebx, 4
+ and ecx, 0fh
+ add ecx, 18
+ shl ebx, cl ; ebx: CacheSize
+ mov [esp + 36], ebx
+ jmp CacheSizeMacro12
+
+CacheSizeMacro11:
+ mov DWORD PTR [esp + 36], -1
+
+CacheSizeMacro12:
+ mov eax, [esp + 16]
+ mov ebx, [esp + 20]
+ mov ecx, [esp + 24]
+ mov edx, [esp + 28]
+ mov ebp, [esp + 32]
+ mov reg, [esp + 36]
+ add esp, 40
+;=========================================
+ENDM
+
+GET_CACHE_SIZE_CORE MACRO reg:REQ
+;=========================================
+ sub esp, 44
+ mov [esp + 16], eax
+ mov [esp + 20], ebx
+ mov [esp + 24], ecx
+ mov [esp + 28], edx
+ mov [esp + 32], ebp
+ mov [esp + 36], reg ; Pointers to the TableCacheSize
+
+ xor eax, eax
+ cpuid
+
+ cmp ebx, 756E6547h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp edx, 49656E69h
+ jne CacheSizeMacro11 ; Not Intel
+ cmp ecx, 6c65746eh
+ jne CacheSizeMacro11 ; Not Intel
+
+ cmp eax, 4
+ jl CoreMacro00
+
+ mov eax, 4
+ xor ecx, ecx
+ cpuid
+ shr eax, 26
+ add eax, 1
+ mov [esp + 40], eax ; cores
+ jmp CacheSizeMacro
+
+CoreMacro00:
+ mov DWORD PTR [esp + 40], 1
+
+CacheSizeMacro:
+ mov eax, 2
+ cpuid
+
+ cmp al, 1
+ jne CacheSizeMacro11
+
+ test eax, 080000000h
+ jz CacheSizeMacro00
+ xor eax, eax
+CacheSizeMacro00:
+ test ebx, 080000000h
+ jz CacheSizeMacro01
+ xor ebx, ebx
+CacheSizeMacro01:
+ test ecx, 080000000h
+ jz CacheSizeMacro02
+ xor ecx, ecx
+CacheSizeMacro02:
+ test edx, 080000000h
+ jz CacheSizeMacro03
+ xor edx, edx
+
+CacheSizeMacro03:
+ mov ebp, esp
+ test eax, eax
+ jz CacheSizeMacro04
+ mov [ebp], eax
+ add ebp, 4
+ mov eax, 3
+CacheSizeMacro04:
+ test ebx, ebx
+ jz CacheSizeMacro05
+ mov [ebp], ebx
+ add ebp, 4
+ add eax, 4
+CacheSizeMacro05:
+ test ecx, ecx
+ jz CacheSizeMacro06
+ mov [ebp], ecx
+ add ebp, 4
+ add eax, 4
+CacheSizeMacro06:
+ test edx, edx
+ jz CacheSizeMacro07
+ mov [ebp], edx
+ add eax, 4
+
+CacheSizeMacro07:
+ mov ebx, [esp + 36] ; ebx: Pointers to the TableCacheSize
+
+ test eax, eax
+ jz CacheSizeMacro11
+CacheSizeMacro08:
+ movzx edx, BYTE PTR [ebx]
+ test edx, edx
+ jz CacheSizeMacro11
+ add ebx, 2
+ mov ecx, eax
+CacheSizeMacro09:
+ cmp dl, BYTE PTR [esp + ecx]
+ je CacheSizeMacro10
+ sub ecx, 1
+ jnz CacheSizeMacro09
+ jmp CacheSizeMacro08
+
+CacheSizeMacro10:
+ movzx eax, BYTE PTR [ebx - 1]
+ mov ecx, eax
+ shr eax, 4
+ and ecx, 0fh
+ add ecx, 18
+ shl eax, cl ; eax: CacheSize
+ mov ecx, [esp + 40] ; ecx: cores
+ xor edx, edx
+ div ecx
+ mov [esp + 36], eax
+ jmp CacheSizeMacro12
+
+CacheSizeMacro11:
+ mov DWORD PTR [esp + 36], -1
+
+CacheSizeMacro12:
+ mov eax, [esp + 16]
+ mov ebx, [esp + 20]
+ mov ecx, [esp + 24]
+ mov edx, [esp + 28]
+ mov ebp, [esp + 32]
+ mov reg, [esp + 36]
+ add esp, 44
+;=========================================
+ENDM
+
+.LIST
diff --git a/ext/ipp/sources/include/ippres.gen b/ext/ipp/sources/include/ippres.gen
new file mode 100644
index 0000000..001a186
--- /dev/null
+++ b/ext/ipp/sources/include/ippres.gen
@@ -0,0 +1,267 @@
+/*******************************************************************************
+* Copyright 1999-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+
+#include "winres.h"
+
+#define STR2(x) #x
+#define STR(x) STR2(x)
+
+#ifndef _IPP_VERSION
+#define _IPP_VERSION ""
+#endif
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VERSION()
+ PRODUCTVERSION VERSION()
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Intel Corporation.\0"
+ VALUE "FileVersion", STR( VERSION() ) "\0"
+ VALUE "ProductName", IPP_LIB_SHORTNAME() ". Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ".\0"
+ VALUE "ProductVersion", STR_VERSION() "\0"
+ VALUE "LegalCopyright", "Copyright (C) 1999-2018, Intel Corporation. All rights reserved.\0"
+
+ #if defined (_CORE) && !defined (_WIN64) && defined (_WIN32) && !defined (_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ".\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_CORE) && defined (_WIN64) && defined (_WIN32) && !defined(_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ".\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "64" IPP_LIB_SHORTNAME() _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() "64" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() "64" _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_CORE) && defined(_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ".\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() IPP_LIB_SHORTNAME() _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && defined(_WIN32E) && !defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && defined(_WIN32E) && defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && defined (_WIN64) && defined (_WIN32) && !defined(_WIN32E) && !defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "64" _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "64" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "64" _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && !defined (_WIN32E) && !defined (_WIN64) && defined (_WIN32) && !defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && !defined (_WIN32E) && !defined (_WIN64) && defined (_WIN32) && defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() GET_STR(IPPVER) _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() GET_STR(IPPVER) _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() GET_STR(IPPVER) _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PCS) && defined (_WIN64) && defined (_WIN32) && !defined(_WIN32E) && defined (IPPVER)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". DLLs dispatcher\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "64" GET_STR(IPPVER) _IPP_VERSION ".dll is the " IPP_LIB_SHORTNAME() " dispatcher\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "64" GET_STR(IPPVER) _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "64" GET_STR(IPPVER) _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PX) && !defined (_WIN64) && defined (_WIN32) && !defined (_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". For Intel(R) Pentium(R) processors\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "px" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "px" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "px" _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PX) && defined(_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". For Intel(R) 64 Instruction Set Architecture (ISA) processors\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "mx" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "mx" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "mx" _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_PX) && defined (_WIN64) && defined (_WIN32) && !defined(_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". For Intel(R) Itanium(R) processors\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "ix" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "ix" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "ix" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _M6
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for Intel(R) Pentium(R) II processor\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "m6" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "m6" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "m6" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _A6
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Streaming SIMD Extensions (SSE)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "a6" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "a6" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "a6" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _W7
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Streaming SIMD Extensions 2 (SSE2)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "w7" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "w7" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "w7" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _T7
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Streaming SIMD Extensions 3 (SSE3)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "t7" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "t7" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "t7" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _V8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Supplemental Streaming SIMD Extension 3 (SSSE3)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "v8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "v8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "v8" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _P8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Streaming SIMD Extensions 4.2 (SSE4.2)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "p8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "p8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "p8" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _G9
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Advanced Vector Extensions (AVX)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "g9" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "g9" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "g9" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _H9
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Advanced Vector Extensions 2 (AVX2)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "h9" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "h9" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "h9" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _M7
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for Intel(R) 64 Instruction Set Architecture (ISA)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "m7" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "m7" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "m7" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _U8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Supplemental Streaming SIMD Extension 3 (SSSE3)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "u8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "u8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "u8" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _Y8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Streaming SIMD Extensions 4.2 (SSE4.2)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "y8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "y8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "y8" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _E9
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Advanced Vector Extensions (AVX)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "e9" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "e9" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "e9" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _L9
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with Advanced Vector Extensions 2 (AVX2)\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "l9" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "l9" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "l9" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _K0
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with AVX512F/CD/BW/DQ/VL support\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "k0" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "k0" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "k0" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _N0
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for processors with AVX512F/CD/ER/PF support\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "n0" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "n0" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "n0" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _S8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for Intel(R) Atom(TM) processor\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "s8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "s8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "s8" _IPP_VERSION ".dll\0"
+ #endif
+ #ifdef _N8
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". Optimized for Intel(R) Atom(TM) processor\0"
+ VALUE "FileDescription", IPP_LIB_PREFIX() "n8" _IPP_VERSION ".dll is an " IPP_LIB_SHORTNAME() " dynamic library\0"
+ VALUE "InternalName", IPP_LIB_PREFIX() "n8" _IPP_VERSION ".dll\0"
+ VALUE "OriginalFilename", IPP_LIB_PREFIX() "n8" _IPP_VERSION ".dll\0"
+ #endif
+ #if defined (_IPP_PS) && defined(_WIN32)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() ". performance test application\0"
+ VALUE "FileDescription", "ps_" IPP_LIB_PREFIX() ".exe is the performance test application for " IPP_LIB_LONGNAME() "\0"
+ VALUE "InternalName", "ps_" IPP_LIB_PREFIX() ".exe\0"
+ VALUE "OriginalFilename", "ps_" IPP_LIB_PREFIX() ".exe\0"
+ #endif
+ #if defined (_IPP_PS) && defined(_WIN32E)
+ VALUE "Comments", "Intel(R) Integrated Performance Primitives. " IPP_LIB_LONGNAME() " performance test application\0"
+ VALUE "FileDescription", "ps_" IPP_LIB_PREFIX() ".exe is the performance test application for " IPP_LIB_LONGNAME() "\0"
+ VALUE "InternalName", "ps_" IPP_LIB_PREFIX() ".exe\0"
+ VALUE "OriginalFilename", "ps_" IPP_LIB_PREFIX() ".exe\0"
+ #endif
+
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
diff --git a/ext/ipp/sources/include/ippver.h b/ext/ipp/sources/include/ippver.h
new file mode 100644
index 0000000..40ef4b7
--- /dev/null
+++ b/ext/ipp/sources/include/ippver.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+* Copyright 2001-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives (Intel(R) IPP)
+// Cryptographic Primitives (ippCP)
+//
+// Purpose: Describes the base Intel(R) IPP version
+//
+//
+*/
+
+
+#include "ippversion.h"
+#ifndef BASE_VERSION
+#define BASE_VERSION() IPP_VERSION_MAJOR,IPP_VERSION_MINOR,IPP_VERSION_UPDATE
+#endif
+
+#ifndef STR_VERSION
+ #ifdef IPP_REVISION
+ #define STR_VERSION() IPP_VERSION_STR " (r" STR( IPP_REVISION ) ")"
+ #else
+ #define STR_VERSION() IPP_VERSION_STR " (-)"
+ #endif
+#endif
+
+
+/* ////////////////////////////// End of file /////////////////////////////// */
diff --git a/ext/ipp/sources/include/owndefs.h b/ext/ipp/sources/include/owndefs.h
index a719059..572a070 100644
--- a/ext/ipp/sources/include/owndefs.h
+++ b/ext/ipp/sources/include/owndefs.h
@@ -1,18 +1,50 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 1999-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+//
+// Intel(R) Integrated Performance Primitives (Intel(R) IPP) Cryptography
+//
+// Purpose:
+// Internal definitions
+//
+//
#ifndef __OWNDEFS_H__
#define __OWNDEFS_H__
@@ -22,7 +54,9 @@
#undef NONE
#endif
-#include "ippdefs.h"
+#ifndef IPPCPDEFS_H__
+ #include "ippcpdefs.h"
+#endif
#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
#define __INLINE static __inline
@@ -55,41 +89,29 @@ typedef struct{
Ipp64u high;
}Ipp128u;
-#define _IPP_PX 0 /* pure C-code ia32 */
-#define _IPP_M5 1 /* Quark (Pentium) - x86+x87 ia32 */
-#define _IPP_M6 2 /* Pentium MMX - MMX ia32 */
-#define _IPP_A6 4 /* Pentium III - SSE ia32 */
-#define _IPP_W7 8 /* Pentium 4 - SSE2 ia32 */
-#define _IPP_T7 16 /* Pentium with x64 support (Nocona) - SSE3 ia32 */
-#define _IPP_V8 32 /* Merom - SSSE3 ia32 */
-#define _IPP_S8 33 /* Atom - SSSE3 ia32 (Silverthorne)+MOVBE */
-#define _IPP_P8 64 /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */
-#define _IPP_G9 128 /* SandyBridge (GSSE) - AVX ia32 */
-#define _IPP_H9 256 /* Haswell (AVX2) ia32 */
-#define _IPP_I0 512 /* KNL (AVX-512) ia32 */
-#define _IPP_S0 1024 /* SkyLake Xeon (AVX-512) ia32 */
-
-#define _IPPXSC_PX 0
-#define _IPPXSC_S1 1
-#define _IPPXSC_S2 2
-#define _IPPXSC_C2 4
-
-#define _IPPLRB_PX 0
-#define _IPPLRB_B1 1
-#define _IPPLRB_B2 2
-
-#define _IPP64_PX _IPP_PX
-#define _IPP64_I7 64
-
-#define _IPP32E_PX _IPP_PX /* pure C-code x64 */
-#define _IPP32E_M7 32 /* Pentium with x64 support (Nocona) - SSE3 x64 */
-#define _IPP32E_U8 64 /* Merom - SSSE3 x64 */
-#define _IPP32E_N8 65 /* Atom - SSSE3 x64 (Silverthorne)+MOVBE */
-#define _IPP32E_Y8 128 /* Penryn - SSE4.1 + tick for SSE4.2 x64 */
-#define _IPP32E_E9 256 /* SandyBridge (GSSE) - AVX x64 */
-#define _IPP32E_L9 512 /* Haswell (AVX2) x64 */
-#define _IPP32E_N0 1024 /* KNL (AVX-512) x64 */
-#define _IPP32E_K0 2048 /* SkyLake Xeon (AVX-512) x64 */
+/* ia32 */
+#define _IPP_PX 0 /* pure C-code */
+#define _IPP_M5 1 /* Intel(R) Quark(TM) processor */
+#define _IPP_W7 8 /* Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) */
+#define _IPP_T7 16 /* Intel(R) Streaming SIMD Extensions 3 (Intel(R) SSE3) */
+#define _IPP_V8 32 /* Supplemental Streaming SIMD Extensions 3 (SSSE3) */
+#define _IPP_S8 33 /* Supplemental Streaming SIMD Extensions 3 (SSSE3) + MOVBE instruction */
+#define _IPP_P8 64 /* Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) */
+#define _IPP_G9 128 /* Intel(R) Advanced Vector Extensions (Intel(R) AVX) */
+#define _IPP_H9 256 /* Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) */
+#define _IPP_I0 512 /* Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX512) - Intel(R) Xeon Phi(TM) Processor (formerly Knights Landing) */
+#define _IPP_S0 1024 /* Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX512) - Intel(R) Xeon(R) Processor (formerly codenamed Skylake) */
+
+/* intel64 */
+#define _IPP32E_PX _IPP_PX /* pure C-code */
+#define _IPP32E_M7 32 /* Intel(R) Streaming SIMD Extensions 3 (Intel(R) SSE3) */
+#define _IPP32E_U8 64 /* Supplemental Streaming SIMD Extensions 3 (SSSE3) */
+#define _IPP32E_N8 65 /* Supplemental Streaming SIMD Extensions 3 (SSSE3) + MOVBE instruction */
+#define _IPP32E_Y8 128 /* Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) */
+#define _IPP32E_E9 256 /* Intel(R) Advanced Vector Extensions (Intel(R) AVX) */
+#define _IPP32E_L9 512 /* Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) */
+#define _IPP32E_N0 1024 /* Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX512) - Intel(R) Xeon Phi(TM) Processor (formerly Knights Landing) */
+#define _IPP32E_K0 2048 /* Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX512) - Intel(R) Xeon(R) Processor (formerly codenamed Skylake) */
#if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300)
@@ -106,124 +128,91 @@ typedef struct{
#error Intel, MS or GNU C compiler required
#endif
-#if defined ( _M5 ) /* Quark (Pentium) - x86+x87 ia32 */
+/* ia32 */
+#if defined ( _M5 ) /* Intel(R) Quark(TM) processor */
#define _IPP _IPP_M5
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) m5_##name
-#elif defined ( _M6 ) /* Pentium MMX - MMX ia32 */
- #define _IPP _IPP_M6
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define OWNAPI(name) m6_##name
-
-#elif defined( _A6 ) /* Pentium III - SSE ia32 */
- #define _IPP _IPP_A6
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define OWNAPI(name) a6_##name
-
-#elif defined( _W7 ) /* Pentium 4 - SSE2 ia32 */
+#elif defined( _W7 ) /* Intel(R) SSE2 */
#define _IPP _IPP_W7
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) w7_##name
-#elif defined( _T7 ) /* Pentium with x64 support (Nocona) - SSE3 ia32 */
+#elif defined( _T7 ) /* Intel(R) SSE3 */
#define _IPP _IPP_T7
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) t7_##name
-#elif defined( _V8 ) /* Merom - SSSE3 ia32 */
+#elif defined( _V8 ) /* SSSE3 */
#define _IPP _IPP_V8
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) v8_##name
-#elif defined( _S8 ) /* old Atom (SSSE3+movbe) (Silverthorne) ia32 */
+#elif defined( _S8 ) /* SSSE3 + MOVBE instruction */
#define _IPP _IPP_S8
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) s8_##name
-#elif defined( _P8 ) /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */
+#elif defined( _P8 ) /* Intel(R) SSE4.2 */
#define _IPP _IPP_P8
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) p8_##name
-#elif defined( _G9 ) /* SandyBridge (GSSE) - AVX ia32 */
+#elif defined( _G9 ) /* Intel(R) AVX */
#define _IPP _IPP_G9
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) g9_##name
-#elif defined( _H9 ) /* Haswell (AVX2) ia32 */
+#elif defined( _H9 ) /* Intel(R) AVX2 */
#define _IPP _IPP_H9
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) h9_##name
-#elif defined( _M7 ) /* Pentium with x64 support (Nocona) - SSE3 x64 */
+/* intel64 */
+#elif defined( _M7 ) /* Intel(R) SSE3 */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_M7
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) m7_##name
-#elif defined( _U8 ) /* Merom - SSSE3 x64 */
+#elif defined( _U8 ) /* SSSE3 */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_U8
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) u8_##name
-#elif defined( _N8 ) /* old Atom (SSSE3+movbe) (Silverthorne) x64 */
+#elif defined( _N8 ) /* SSSE3 + MOVBE instruction */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_N8
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) n8_##name
-#elif defined( _Y8 ) /* Penryn - SSE4.1 + tick for SSE4.2 x64 */
+#elif defined( _Y8 ) /* Intel(R) SSE4.2 */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_Y8
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) y8_##name
-#elif defined( _E9 ) /* SandyBridge (GSSE) - AVX x64 */
+#elif defined( _E9 ) /* Intel(R) AVX */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_E9
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) e9_##name
-#elif defined( _L9 ) /* Haswell (AVX2) x64 */
+#elif defined( _L9 ) /* Intel(R) AVX2 */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_L9
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) l9_##name
-#elif defined( _N0 ) /* KNL (AVX-512) x64 */
+#elif defined( _N0 ) /* Intel(R) AVX512 - formerly Knights Landing */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_N0
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) n0_##name
-#elif defined( _K0 ) /* SkyLake Xeon (AVX-512) x64 */
+#elif defined( _K0 ) /* Intel(R) AVX512 - formerly codenamed Skylake */
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_K0
- #define _IPPLRB _IPPLRB_PX
#define OWNAPI(name) k0_##name
-#elif defined( _B2 ) /* KNC (MIC) */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_B2
- #define OWNAPI(name) b2_##name
-
#else
#define _IPP _IPP_PX
#define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
#if defined (_M_AMD64) || defined (__x86_64__) || defined ( _ARCH_EM64T )
#define OWNAPI(name) mx_##name
#else
@@ -247,11 +236,7 @@ typedef struct{
#endif
#define _IPP_ARCH_IA32 1
-#define _IPP_ARCH_IA64 2
#define _IPP_ARCH_EM64T 4
-#define _IPP_ARCH_XSC 8
-#define _IPP_ARCH_LRB 16
-#define _IPP_ARCH_LRB2 128
#if defined ( _ARCH_IA32 )
#define _IPP_ARCH _IPP_ARCH_IA32
@@ -259,9 +244,6 @@ typedef struct{
#elif defined( _ARCH_EM64T )
#define _IPP_ARCH _IPP_ARCH_EM64T
-#elif defined( _ARCH_LRB2 )
- #define _IPP_ARCH _IPP_ARCH_LRB2
-
#else
#if defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__)
#define _IPP_ARCH _IPP_ARCH_EM64T
@@ -338,7 +320,7 @@ extern "C" {
/* /////////////////////////////////////////////////////////////////////////////
- IPP Context Identification
+ Intel(R) IPP Context Identification
/////////////////////////////////////////////////////////////////////////// */
@@ -348,145 +330,10 @@ extern "C" {
typedef enum {
idCtxUnknown = 0,
- idCtxFFT_C_16sc,
- idCtxFFT_C_16s,
- idCtxFFT_R_16s,
- idCtxFFT_C_32fc,
- idCtxFFT_C_32f,
- idCtxFFT_R_32f,
- idCtxFFT_C_64fc,
- idCtxFFT_C_64f,
- idCtxFFT_R_64f,
- idCtxDFT_C_16sc,
- idCtxDFT_C_16s,
- idCtxDFT_R_16s,
- idCtxDFT_C_32fc,
- idCtxDFT_C_32f,
- idCtxDFT_R_32f,
- idCtxDFT_C_64fc,
- idCtxDFT_C_64f,
- idCtxDFT_R_64f,
- idCtxDCTFwd_16s,
- idCtxDCTInv_16s,
- idCtxDCTFwd_32f,
- idCtxDCTInv_32f,
- idCtxDCTFwd_64f,
- idCtxDCTInv_64f,
- idCtxFFT2D_C_32fc,
- idCtxFFT2D_R_32f,
- idCtxDFT2D_C_32fc,
- idCtxDFT2D_R_32f,
- idCtxFFT2D_R_32s,
- idCtxDFT2D_R_32s,
- idCtxDCT2DFwd_32f,
- idCtxDCT2DInv_32f,
- idCtxMoment64f,
- idCtxMoment64s,
- idCtxRandUni_8u,
- idCtxRandUni_16s,
- idCtxRandUni_32f,
- idCtxRandUni_64f,
- idCtxRandGauss_8u,
- idCtxRandGauss_16s,
- idCtxRandGauss_32f,
- idCtxRandGauss_64f,
- idCtxWTFwd_32f,
- idCtxWTFwd_8u32f,
- idCtxWTFwd_8s32f,
- idCtxWTFwd_16u32f,
- idCtxWTFwd_16s32f,
- idCtxWTFwd2D_32f_C1R,
- idCtxWTInv2D_32f_C1R,
- idCtxWTFwd2D_32f_C3R,
- idCtxWTInv2D_32f_C3R,
- idCtxWTInv_32f,
- idCtxWTInv_32f8u,
- idCtxWTInv_32f8s,
- idCtxWTInv_32f16u,
- idCtxWTInv_32f16s,
- idCtxMDCTFwd_32f,
- idCtxMDCTInv_32f,
- idCtxMDCTFwd_16s,
- idCtxFIRBlock_32f,
- idCtxFDP_32f,
- idCtxRLMS_32f = IPP_CONTEXT( 'L', 'M', 'S', '1'),
- idCtxRLMS32f_16s = IPP_CONTEXT( 'L', 'M', 'S', 0 ),
- idCtxIIRAR_32f = IPP_CONTEXT( 'I', 'I', '0', '1'),
- idCtxIIRBQ_32f = IPP_CONTEXT( 'I', 'I', '0', '2'),
- idCtxIIRAR_32fc = IPP_CONTEXT( 'I', 'I', '0', '3'),
- idCtxIIRBQ_32fc = IPP_CONTEXT( 'I', 'I', '0', '4'),
- idCtxIIRAR32f_16s = IPP_CONTEXT( 'I', 'I', '0', '5'),
- idCtxIIRBQ32f_16s = IPP_CONTEXT( 'I', 'I', '0', '6'),
- idCtxIIRAR32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '7'),
- idCtxIIRBQ32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '8'),
- idCtxIIRAR32s_16s = IPP_CONTEXT( 'I', 'I', '0', '9'),
- idCtxIIRBQ32s_16s = IPP_CONTEXT( 'I', 'I', '1', '0'),
- idCtxIIRAR32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '1'),
- idCtxIIRBQ32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '2'),
- idCtxIIRAR_64f = IPP_CONTEXT( 'I', 'I', '1', '3'),
- idCtxIIRBQ_64f = IPP_CONTEXT( 'I', 'I', '1', '4'),
- idCtxIIRAR_64fc = IPP_CONTEXT( 'I', 'I', '1', '5'),
- idCtxIIRBQ_64fc = IPP_CONTEXT( 'I', 'I', '1', '6'),
- idCtxIIRAR64f_32f = IPP_CONTEXT( 'I', 'I', '1', '7'),
- idCtxIIRBQ64f_32f = IPP_CONTEXT( 'I', 'I', '1', '8'),
- idCtxIIRAR64fc_32fc = IPP_CONTEXT( 'I', 'I', '1', '9'),
- idCtxIIRBQ64fc_32fc = IPP_CONTEXT( 'I', 'I', '2', '0'),
- idCtxIIRAR64f_32s = IPP_CONTEXT( 'I', 'I', '2', '1'),
- idCtxIIRBQ64f_32s = IPP_CONTEXT( 'I', 'I', '2', '2'),
- idCtxIIRAR64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '3'),
- idCtxIIRBQ64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '4'),
- idCtxIIRAR64f_16s = IPP_CONTEXT( 'I', 'I', '2', '5'),
- idCtxIIRBQ64f_16s = IPP_CONTEXT( 'I', 'I', '2', '6'),
- idCtxIIRAR64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '7'),
- idCtxIIRBQ64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '8'),
- idCtxIIRBQDF1_32f = IPP_CONTEXT( 'I', 'I', '2', '9'),
- idCtxIIRBQDF164f_32s= IPP_CONTEXT( 'I', 'I', '3', '0'),
- idCtxFIRSR_32f = IPP_CONTEXT( 'F', 'I', '0', '1'),
- idCtxFIRSR_32fc = IPP_CONTEXT( 'F', 'I', '0', '2'),
- idCtxFIRMR_32f = IPP_CONTEXT( 'F', 'I', '0', '3'),
- idCtxFIRMR_32fc = IPP_CONTEXT( 'F', 'I', '0', '4'),
- idCtxFIRSR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '5'),
- idCtxFIRSR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '6'),
- idCtxFIRMR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '7'),
- idCtxFIRMR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '8'),
- idCtxFIRSR32s_16s = IPP_CONTEXT( 'F', 'I', '0', '9'),
- idCtxFIRSR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '0'),
- idCtxFIRMR32s_16s = IPP_CONTEXT( 'F', 'I', '1', '1'),
- idCtxFIRMR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '2'),
- idCtxFIRSR_64f = IPP_CONTEXT( 'F', 'I', '1', '3'),
- idCtxFIRSR_64fc = IPP_CONTEXT( 'F', 'I', '1', '4'),
- idCtxFIRMR_64f = IPP_CONTEXT( 'F', 'I', '1', '5'),
- idCtxFIRMR_64fc = IPP_CONTEXT( 'F', 'I', '1', '6'),
- idCtxFIRSR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '7'),
- idCtxFIRSR64fc_32fc = IPP_CONTEXT( 'F', 'I', '1', '8'),
- idCtxFIRMR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '9'),
- idCtxFIRMR64fc_32fc = IPP_CONTEXT( 'F', 'I', '2', '0'),
- idCtxFIRSR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '1'),
- idCtxFIRSR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '2'),
- idCtxFIRMR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '3'),
- idCtxFIRMR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '4'),
- idCtxFIRSR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '5'),
- idCtxFIRSR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '6'),
- idCtxFIRMR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '7'),
- idCtxFIRMR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '8'),
- idCtxFIRSR_16s = IPP_CONTEXT( 'F', 'I', '2', '9'),
- idCtxFIRMR_16s = IPP_CONTEXT( 'F', 'I', '3', '0'),
- idCtxFIRSRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '1'),
- idCtxFIRMRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '2'),
- idCtxFIRSRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '3'),
- idCtxFIRMRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '4'),
- idCtxFIRMR32f_32fc = IPP_CONTEXT( 'F', 'I', '3', '5'),
- idCtxRLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'R'),
- idCtxCLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'C'),
- idCtxEncode_JPEG2K,
idCtxDES = IPP_CONTEXT( ' ', 'D', 'E', 'S'),
- idCtxBlowfish = IPP_CONTEXT( ' ', ' ', 'B', 'F'),
idCtxRijndael = IPP_CONTEXT( ' ', 'R', 'I', 'J'),
idCtxSMS4 = IPP_CONTEXT( 'S', 'M', 'S', '4'),
- idCtxTwofish = IPP_CONTEXT( ' ', ' ', 'T', 'F'),
idCtxARCFOUR = IPP_CONTEXT( ' ', 'R', 'C', '4'),
- idCtxRC564 = IPP_CONTEXT( 'R', 'C', '5', '1'),
- idCtxRC5128 = IPP_CONTEXT( 'R', 'C', '5', '2'),
idCtxSHA1 = IPP_CONTEXT( 'S', 'H', 'S', '1'),
idCtxSHA224 = IPP_CONTEXT( 'S', 'H', 'S', '3'),
idCtxSHA256 = IPP_CONTEXT( 'S', 'H', 'S', '2'),
@@ -494,7 +341,6 @@ typedef enum {
idCtxSHA512 = IPP_CONTEXT( 'S', 'H', 'S', '5'),
idCtxMD5 = IPP_CONTEXT( ' ', 'M', 'D', '5'),
idCtxHMAC = IPP_CONTEXT( 'H', 'M', 'A', 'C'),
- idCtxDAA = IPP_CONTEXT( ' ', 'D', 'A', 'A'),
idCtxBigNum = IPP_CONTEXT( 'B', 'I', 'G', 'N'),
idCtxMontgomery = IPP_CONTEXT( 'M', 'O', 'N', 'T'),
idCtxPrimeNumber = IPP_CONTEXT( 'P', 'R', 'I', 'M'),
@@ -511,64 +357,9 @@ typedef enum {
idCtxDH = IPP_CONTEXT( ' ', ' ', 'D', 'H'),
idCtxDLP = IPP_CONTEXT( ' ', 'D', 'L', 'P'),
idCtxCMAC = IPP_CONTEXT( 'C', 'M', 'A', 'C'),
- idCtxRFFT2_8u,
- idCtxHilbert_32f32fc,
- idCtxHilbert_16s32fc,
- idCtxHilbert_16s16sc,
- idCtxTone_16s,
- idCtxTriangle_16s,
- idCtxDFTOutOrd_C_32fc,
- idCtxDFTOutOrd_C_64fc,
- idCtxFFT_C_32sc,
- idCtxFFT_C_32s,
- idCtxFFT_R_32s,
- idCtxFFT_R_16s32s,
- idCtxDecodeProgr_JPEG2K,
- idCtxWarp_MPEG4,
- idCtxQuantInvIntra_MPEG4,
- idCtxQuantInvInter_MPEG4,
- idCtxQuantIntra_MPEG4,
- idCtxQuantInter_MPEG4,
- idCtxAnalysisFilter_SBR_C_32f32fc,
- idCtxAnalysisFilter_SBR_C_32f,
- idCtxAnalysisFilter_SBR_R_32f,
- idCtxSynthesisFilter_SBR_C_32fc32f,
- idCtxSynthesisFilter_SBR_C_32f,
- idCtxSynthesisFilter_SBR_R_32f,
- idCtxSynthesisDownFilter_SBR_C_32fc32f,
- idCtxSynthesisDownFilter_SBR_C_32f,
- idCtxSynthesisDownFilter_SBR_R_32f,
- idCtxVLCEncode,
- idCtxVLCDecode,
- idCtxAnalysisFilter_SBR_C_32s32sc,
- idCtxAnalysisFilter_SBR_R_32s,
- idCtxSynthesisFilter_SBR_C_32sc32s,
- idCtxSynthesisFilter_SBR_R_32s,
- idCtxSynthesisDownFilter_SBR_C_32sc32s,
- idCtxSynthesisDownFilter_SBR_R_32s,
- idCtxSynthesisFilter_PQMF_MP3_32f,
- idCtxAnalysisFilter_PQMF_MP3_32f,
- idCtxResampleRow,
- idCtxAnalysisFilter_SBR_Enc_C_32f32fc,
- idCtxSynthesisFilter_DTS_32f,
- idCtxFilterBilateralGauss_8u,
- idCtxFilterBilateralGaussFast_8u,
- idCtxBGF,
- idCtxPolyGF,
- idCtxRSenc,
- idCtxRSdec,
- idCtxSnow3g = IPP_CONTEXT( 'S', 'n', 'o', 'w'),
- idCtxSnow3gF8,
- idCtxSnow3gF9,
- idCtxKasumi = IPP_CONTEXT( 'K', 'a', 's', 'u'),
- idCtxKasumiF8,
- idCtxKasumiF9,
- idCtxResizeHannFilter_8u,
- idCtxResizeLanczosFilter_8u,
idCtxAESXCBC,
idCtxAESCCM,
idCtxAESGCM,
- idCtxMsgCatalog,
idCtxGFP,
idCtxGFPE,
idCtxGFPX,
@@ -579,22 +370,10 @@ typedef enum {
idCtxGFPPoint,
idCtxGFPXEC,
idCtxGFPXECPoint,
- idCtxPairing,
- idCtxResize,
- idCtxResizeYUV420,
- idCtxResizeYUV422,
- idCtxResize_L,
- idCtxFilterBilateralBorder,
- idCtxThresholdAdaptiveGauss,
- idCtxHOG,
- idCtxFastN,
idCtxHash,
idCtxSM3,
idCtxAESXTS,
- idCtxWarpAffine,
- idCtxWarpAffine_L,
- idCtxWarpPerspective,
- idCtxWarpPerspective_L
+ idxCtxECES_SM2
} IppCtxId;
@@ -661,71 +440,6 @@ typedef union { /* single precision */
} IppFP_32f;
-extern const IppFP_32f ippConstantOfNAN_32f;
-extern const IppFP_64f ippConstantOfNAN_64f;
-
-extern const IppFP_32f ippConstantOfINF_32f;
-extern const IppFP_64f ippConstantOfINF_64f;
-extern const IppFP_32f ippConstantOfINF_NEG_32f;
-extern const IppFP_64f ippConstantOfINF_NEG_64f;
-
-#define NAN_32F (ippConstantOfNAN_32f.fp)
-#define NAN_64F (ippConstantOfNAN_64f.fp)
-#define INF_32F (ippConstantOfINF_32f.fp)
-#define INF_64F (ippConstantOfINF_64f.fp)
-#define INF_NEG_32F (ippConstantOfINF_NEG_32f.fp)
-#define INF_NEG_64F (ippConstantOfINF_NEG_64f.fp)
-
-/* ////////////////////////////////////////////////////////////////////////// */
-
-typedef enum {
- ippunreg=-1,
- ippac = 0,
- ippcc = 1,
- ippch = 2,
- ippcp = 3,
- ippcv = 4,
- ippdc = 5,
- ippdi = 6,
- ippgen = 7,
- ippi = 8,
- ippj = 9,
- ippm = 10,
- ippr = 11,
- ipps = 12,
- ippsc = 13,
- ippsr = 14,
- ippvc = 15,
- ippvm = 16,
- ippmsdk = 17,
- ippe = 18,
- ipprs = 19,
- ippsq = 20,
- ippnomore
-} IppDomain;
-
-int IPP_CDECL ownGetNumThreads( void );
-int IPP_CDECL ownGetFeature( Ipp64u MaskOfFeature ); /* the main function of tick-tock dispatcher */
-
-#ifdef _IPP_DYNAMIC
-typedef IppStatus (IPP_STDCALL *DYN_RELOAD)( int );
-void IPP_CDECL ownRegisterLib( IppDomain, DYN_RELOAD );
-void IPP_CDECL ownUnregisterLib( IppDomain );
-IPP_INT64 IPP_CDECL ippStartTscp (void);
-IPP_INT64 IPP_CDECL ippStopTscp (void);
-IPP_INT64 IPP_CDECL ippStartTsc (void);
-IPP_INT64 IPP_CDECL ippStopTsc (void);
-#endif
-
-/* the number of threads available for any ipp function that uses OMP; */
-/* at the ippxx.dll loading time is equal to the number of logical processors, */
-/* and can be changed ONLY externally by library user to any desired number */
-/* by means of ippSetNumThreads() function */
-#define IPP_GET_NUM_THREADS() ( ownGetNumThreads() )
-#define IPP_OMP_NUM_THREADS() num_threads( IPP_GET_NUM_THREADS() )
-#define IPP_OMP_LIMIT_MAX_NUM_THREADS(n) num_threads( IPP_MIN(IPP_GET_NUM_THREADS(),(n)))
-
-
/* ////////////////////////////////////////////////////////////////////////// */
/* Define NULL pointer value */
@@ -737,7 +451,7 @@ IPP_INT64 IPP_CDECL ippStopTsc (void);
#endif
#endif
-#define UNREFERENCED_PARAMETER(p) (p)=(p)
+#define UNREFERENCED_PARAMETER(p) (void)(p)
#if defined( _IPP_MARK_LIBRARY )
static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210, 207, 215};
@@ -775,11 +489,9 @@ static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210,
/* ////////////////////////////////////////////////////////////////////////// */
/* intrinsics */
-#if (_IPP >= _IPP_A6) || (_IPP32E >= _IPP32E_M7)
+#if (_IPP >= _IPP_W7) || (_IPP32E >= _IPP32E_M7)
#if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300)
- #if (_IPP == _IPP_A6)
- #include "xmmintrin.h"
- #elif (_IPP == _IPP_W7)
+ #if (_IPP == _IPP_W7)
#if defined(__INTEL_COMPILER)
#include "emmintrin.h"
#else
@@ -788,7 +500,7 @@ static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210,
#define _W7
#endif
#define _mm_loadu _mm_loadu_si128
- #elif (_IPP == _IPP_T7) || (_IPP32E == _IPP32E_M7)
+ #elif (_IPP32E == _IPP32E_M7)
#if defined(__INTEL_COMPILER)
#include "pmmintrin.h"
#define _mm_loadu _mm_lddqu_si128
@@ -831,10 +543,6 @@ static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210,
#endif
#endif
#endif
-#elif (_IPPLRB >= _IPPLRB_B2)
- #if defined(__INTEL_COMPILER) || defined(_REF_LIB)
- #include "immintrin.h"
- #endif
#endif
// **** intrinsics for bit casting ****
@@ -904,17 +612,10 @@ extern double __intel_castu64_f64(unsigned __int64 val);
#else
#define __IVDEP message("message :: 'ivdep' is not defined")
#endif
-//usage: #pragma __IVDEP
-/* //////////////////////////////////////////////////////////////////////////
- _IPP_DATA shoul be defined only:
- - if compile not merged library
- - only for 1 CPU for merged library to avoid data duplication
-*/
-#if defined( _MERGED_BLD ) && ( defined(_G9) || defined(_E9) ) /* compile data only for g9 and e9 CPU */
- #define _IPP_DATA 1
-#elif !defined( _MERGED_BLD ) /* compile data if it isn't merged library */
- #define _IPP_DATA 1
+#if !defined( _MERGED_BLD ) /* compile data if it isn't merged library */
+ #undef _IPP_DATA
+ #define _IPP_DATA
#endif
diff --git a/ext/ipp/sources/ippcp/Makefile b/ext/ipp/sources/ippcp/Makefile
deleted file mode 100644
index 7fc4eab..0000000
--- a/ext/ipp/sources/ippcp/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/make -f
-
-API_INCLUDE_DIR = ../../include
-SRC_INCLUDE_DIR = ../../sources/include
-LIB_INSTALL_DIR = $(epidinstalldir)/lib/posix-$(ARCH)/
-
-PCP_INCLUDE_DIR = ./src
-PCP_SRC = $(wildcard ./src/*.c)
-PCP_OBJ = $(PCP_SRC:.c=.o)
-PCP_LIB = ./src/libippcp.a
-
-
-$(PCP_OBJ): %.o: %.c
- $(CC) $(CFLAGS) $(IPP_FLAGS) -I$(API_INCLUDE_DIR) -I$(SRC_INCLUDE_DIR) -I$(PCP_INCLUDE_DIR) -c -o $@ $<
-
-$(PCP_LIB): $(PCP_OBJ)
- $(AR) rc $@ $^
- $(RANLIB) $@
-
-build: all
-
-all: $(PCP_LIB)
-
-install:
- mkdir -p '$(LIB_INSTALL_DIR)'
- cp $(PCP_LIB) '$(LIB_INSTALL_DIR)'
-
-clean:
- rm -f $(PCP_OBJ) $(PCP_LIB)
-
-
diff --git a/ext/ipp/sources/ippcp/cpinit.c b/ext/ipp/sources/ippcp/cpinit.c
new file mode 100644
index 0000000..267a1db
--- /dev/null
+++ b/ext/ipp/sources/ippcp/cpinit.c
@@ -0,0 +1,621 @@
+/*******************************************************************************
+* Copyright 2001-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#if defined( _OPENMP )
+ #include <omp.h>
+#endif
+
+#include "owndefs.h"
+#include "ippcpdefs.h"
+#include "ippcp.h"
+#ifdef _PCS
+#undef _PCS
+#define _MY_PCS_DISABLED
+#endif
+#include "dispatcher.h"
+#ifdef _MY_PCS_DISABLED
+#define _PCS
+#endif
+#if defined( _IPP_DATA )
+
+static Ipp64u cpFeatures = 0;
+static Ipp64u cpFeaturesMask = 0;
+
+static int cpGetFeatures( Ipp64u* pFeaturesMask );
+extern void IPP_CDECL cpGetReg( int* buf, int valEAX, int valECX );
+extern int IPP_CDECL cp_is_avx_extension();
+extern int IPP_CDECL cp_is_avx512_extension();
+IppStatus owncpSetCpuFeaturesAndIdx( Ipp64u cpuFeatures, int* index );
+
+IPPFUN( Ipp64u, ippcpGetEnabledCpuFeatures, ( void ))
+{
+ return cpFeaturesMask;
+}
+
+/*===================================================================*/
+IPPFUN( IppStatus, ippcpGetCpuFeatures, ( Ipp64u* pFeaturesMask ))
+{
+ IPP_BAD_PTR1_RET( pFeaturesMask )
+ {
+ if( 0 != cpFeatures){
+ *pFeaturesMask = cpFeatures;// & cpFeaturesMask;
+ } else {
+ int ret = cpGetFeatures( pFeaturesMask );
+ if( !ret ) return ippStsNotSupportedCpu;
+ }
+ return ippStsNoErr;
+ }
+}
+
+/*===================================================================*/
+
+int cpGetFeature( Ipp64u Feature )
+{
+ if(( cpFeaturesMask & Feature ) == Feature ){
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+int k0_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int n0_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int l9_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int e9_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int y8_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+
+int h9_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int g9_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+int p8_cpGetFeature( Ipp64u Feature ){
+ if(( cpFeaturesMask & Feature ) == Feature ) return 1;
+ else return 0; }
+
+/*===================================================================*/
+#define BIT00 0x00000001
+#define BIT01 0x00000002
+#define BIT02 0x00000004
+#define BIT03 0x00000008
+#define BIT04 0x00000010
+#define BIT05 0x00000020
+#define BIT06 0x00000040
+#define BIT07 0x00000080
+#define BIT08 0x00000100
+#define BIT09 0x00000200
+#define BIT10 0x00000400
+#define BIT11 0x00000800
+#define BIT12 0x00001000
+#define BIT13 0x00002000
+#define BIT14 0x00004000
+#define BIT15 0x00008000
+#define BIT16 0x00010000
+#define BIT17 0x00020000
+#define BIT18 0x00040000
+#define BIT19 0x00080000
+#define BIT20 0x00100000
+#define BIT21 0x00200000
+#define BIT22 0x00400000
+#define BIT23 0x00800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+
+
+static int cpGetFeatures( Ipp64u* pFeaturesMask )
+{
+ Ipp32u buf[4];
+ Ipp32u eax_, ebx_, ecx_, edx_, tmp;
+ Ipp64u mask;
+ int flgFMA=0, flgINT=0, flgGPR=0; // for avx2
+ Ipp32u idBaseMax, idExtdMax;
+
+ cpGetReg((int*)buf, 0, 0); //get max value for basic info.
+ idBaseMax = buf[0];
+ cpGetReg((int*)buf, 0x80000000, 0); //get max value for extended info.
+ idExtdMax = buf[0];
+
+ cpGetReg( (int*)buf, 1, 0 );
+ eax_ = (Ipp32u)buf[0];
+ ecx_ = (Ipp32u)buf[2];
+ edx_ = (Ipp32u)buf[3];
+ mask = 0;
+ if( edx_ & BIT23 ) mask |= ippCPUID_MMX; // edx[23] - MMX(TM) Technology
+ if( edx_ & BIT25 ) mask |= ippCPUID_SSE; // edx[25] - Intel(R) Streaming SIMD Extensions (Intel(R) SSE)
+ if( edx_ & BIT26 ) mask |= ippCPUID_SSE2; // edx[26] - Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2)
+ if( ecx_ & BIT00 ) mask |= ippCPUID_SSE3; // ecx[0] - Intel(R) Streaming SIMD Extensions 3 (Intel(R) SSE3) (formerly codenamed Prescott)
+ if( ecx_ & BIT09 ) mask |= ippCPUID_SSSE3; // ecx[9] - Supplemental Streaming SIMD Extensions 3 (SSSE3) (formerly codenamed Merom)
+ if( ecx_ & BIT22 ) mask |= ippCPUID_MOVBE; // ecx[22] - Intel(R) instruction MOVBE (Intel Atom(R) processor)
+ if( ecx_ & BIT19 ) mask |= ippCPUID_SSE41; // ecx[19] - Intel(R) Streaming SIMD Extensions 4.1 (Intel(R) SSE4.1) (formerly codenamed Penryn)
+ if( ecx_ & BIT20 ) mask |= ippCPUID_SSE42; // ecx[20] - Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) (formerly codenamed Nenalem)
+ if( ecx_ & BIT28 ) mask |= ippCPUID_AVX; // ecx[28] - Intel(R) Advanced Vector Extensions (Intel(R) AVX) (formerly codenamed Sandy Bridge)
+ if(( ecx_ & 0x18000000 ) == 0x18000000 ){
+ tmp = (Ipp32u)cp_is_avx_extension();
+ if( tmp & BIT00 ) mask |= ippAVX_ENABLEDBYOS; // Intel(R) AVX is supported by OS
+ }
+ if( ecx_ & BIT25 ) mask |= ippCPUID_AES; // ecx[25] - Intel(R) AES New Instructions
+ if( ecx_ & BIT01 ) mask |= ippCPUID_CLMUL; // ecx[1] - Intel(R) instruction PCLMULQDQ
+ if( ecx_ & BIT30 ) mask |= ippCPUID_RDRAND; // ecx[30] - Intel(R) instruction RDRRAND
+ if( ecx_ & BIT29 ) mask |= ippCPUID_F16C; // ecx[29] - Intel(R) instruction F16C
+ // Intel(R) AVX2 instructions extention: only if 3 features are enabled at once:
+ // FMA, Intel(R) AVX 256 int & GPR BMI (bit-manipulation);
+ if( ecx_ & BIT12 ) flgFMA = 1; else flgFMA = 0; // ecx[12] - FMA 128 & 256 bit
+ if( idBaseMax >= 7 ){ // get CPUID.eax = 7
+ cpGetReg( (int*)buf, 0x7, 0 );
+ ebx_ = (Ipp32u)buf[1];
+ ecx_ = (Ipp32u)buf[2];
+ edx_ = (Ipp32u)buf[3];
+ if( ebx_ & BIT05 ) flgINT = 1;
+ else flgINT = 0; //ebx[5], Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) (int 256bits)
+ // ebx[3] - enabled ANDN, BEXTR, BLSI, BLSMK, BLSR, TZCNT
+ // ebx[8] - enabled BZHI, MULX, PDEP, PEXT, RORX, SARX, SHLX, SHRX
+ if(( ebx_ & BIT03 )&&( ebx_ & BIT08 )) flgGPR = 1;
+ else flgGPR = 0; // VEX-encoded GPR instructions (GPR BMI)
+ // Intel(R) architecture formerly codenamed Broadwell instructions extention
+ if( ebx_ & BIT19 ) mask |= ippCPUID_ADCOX; // eax[0x7] -->> ebx:: Bit 19: Intel(R) instructions ADOX/ADCX
+ if( ebx_ & BIT18 ) mask |= ippCPUID_RDSEED; // eax[0x7] -->> ebx:: Bit 18: Intel(R) instruction RDSEED
+ if( ebx_ & BIT29 ) mask |= ippCPUID_SHA; // eax[0x7] -->> ebx:: Bit 29: Intel(R) Secure Hash Algorithm Extensions
+ // Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) extention
+ if(cp_is_avx512_extension()){
+ mask |= ippAVX512_ENABLEDBYOS; // Intel(R) AVX-512 is supported by OS
+ }
+ if( ebx_ & BIT16 ) mask |= ippCPUID_AVX512F; // ebx[16] - Intel(R) AVX-512 Foundation
+ if( ebx_ & BIT26 ) mask |= ippCPUID_AVX512PF; // ebx[26] - Intel(R) AVX-512 Prefetch instructions
+ if( ebx_ & BIT27 ) mask |= ippCPUID_AVX512ER; // ebx[27] - Intel(R) AVX-512 Exponential and Reciprocal instructions
+ if( ebx_ & BIT28 ) mask |= ippCPUID_AVX512CD; // ebx[28] - Intel(R) AVX-512 Conflict Detection
+ if( ebx_ & BIT17 ) mask |= ippCPUID_AVX512DQ; // ebx[17] - Intel(R) AVX-512 Dword & Quadword
+ if( ebx_ & BIT30 ) mask |= ippCPUID_AVX512BW; // ebx[30] - Intel(R) AVX-512 Byte & Word
+ if( ebx_ & BIT31 ) mask |= ippCPUID_AVX512VL; // ebx[31] - Intel(R) AVX-512 Vector Length extensions
+ if( ecx_ & BIT01 ) mask |= ippCPUID_AVX512VBMI; // ecx[01] - Intel(R) AVX-512 Vector Byte Manipulation Instructions
+ if( edx_ & BIT02 ) mask |= ippCPUID_AVX512_4VNNIW; // edx[02] - Intel(R) AVX-512 Vector instructions for deep learning enhanced word variable precision
+ if( edx_ & BIT03 ) mask |= ippCPUID_AVX512_4FMADDPS; // edx[03] - Intel(R) AVX-512 Vector instructions for deep learning floating-point single precision
+ // bitwise OR between ippCPUID_MPX & ippCPUID_AVX flags can be used to define that arch is GE than formerly codenamed Skylake
+ if( ebx_ & BIT14 ) mask |= ippCPUID_MPX; // ebx[14] - Intel(R) Memory Protection Extensions (Intel(R) MPX)
+ if( ebx_ & BIT21 ) mask |= ippCPUID_AVX512IFMA; // ebx[21] - Intel(R) AVX-512 IFMA PMADD52
+ }
+ mask = ( flgFMA && flgINT && flgGPR ) ? (mask | ippCPUID_AVX2) : mask; // to separate Intel(R) AVX2 flags here
+
+ if( idExtdMax >= 0x80000001 ){ // get CPUID.eax=0x80000001
+ cpGetReg( (int*)buf, 0x80000001, 0 );
+ ecx_ = (Ipp32u)buf[2];
+ // Intel(R) architecture formerly codenamed Broadwell instructions extention
+ if( ecx_ & BIT08 ) mask |= ippCPUID_PREFETCHW; // eax[0x80000001] -->> ecx:: Bit 8: Intel(R) instruction PREFETCHW
+ }
+ // Intel(R) architecture formerly codenamed Knights Corner
+ if(((( eax_ << 20 ) >> 24 ) ^ 0xb1 ) == 0 ){
+ mask = mask | ippCPUID_KNC;
+ }
+ cpFeatures = mask;
+ cpFeaturesMask = mask; /* all CPU features are enabled by default */
+ *pFeaturesMask = cpFeatures;
+ return 1; /* if somebody need to check for cpuid support - do it at the top of function and return 0 if it's not supported */
+}
+
+int ippcpJumpIndexForMergedLibs = -1;
+static int cpthreads_omp_of_n_ipp = 1;
+
+IPPFUN( int, ippcpGetEnabledNumThreads,( void ))
+{
+ return cpthreads_omp_of_n_ipp;
+}
+
+
+#define AVX3X_FEATURES ( ippCPUID_AVX512F|ippCPUID_AVX512CD|ippCPUID_AVX512VL|ippCPUID_AVX512BW|ippCPUID_AVX512DQ )
+#define AVX3M_FEATURES ( ippCPUID_AVX512F|ippCPUID_AVX512CD|ippCPUID_AVX512PF|ippCPUID_AVX512ER )
+// AVX3X_FEATURES means Intel(R) Xeon(R) processor
+// AVX3M_FEATURES means Intel(R) Many Integrated Core Architecture
+
+
+IppStatus owncpFeaturesToIdx( Ipp64u* cpuFeatures, int* index )
+{
+ IppStatus ownStatus = ippStsNoErr;
+ Ipp64u mask = 0;
+
+ *index = 0;
+
+ if(( AVX3X_FEATURES == ( *cpuFeatures & AVX3X_FEATURES ))&&
+ ( ippAVX512_ENABLEDBYOS & cpFeatures )){ /* Intel(R) architecture formerlySkylake ia32=S0, x64=K0 */
+ mask = AVX3X_MSK;
+ *index = LIB_AVX3X;
+ } else
+ if(( AVX3M_FEATURES == ( *cpuFeatures & AVX3M_FEATURES ))&&
+ ( ippAVX512_ENABLEDBYOS & cpFeatures )){ /* Intel(R) architecture formerly codenamed Knights Landing ia32=i0, x64=N0 */
+ mask = AVX3M_MSK;
+ *index = LIB_AVX3M;
+ } else
+ if(( ippCPUID_AVX2 == ( *cpuFeatures & ippCPUID_AVX2 ))&&
+ ( ippAVX_ENABLEDBYOS & cpFeatures )){ /* Intel(R) architecture formerly codenamed Haswell ia32=H9, x64=L9 */
+ mask = AVX2_MSK;
+ *index = LIB_AVX2;
+ } else
+ if(( ippCPUID_AVX == ( *cpuFeatures & ippCPUID_AVX ))&&
+ ( ippAVX_ENABLEDBYOS & cpFeatures )){ /* Intel(R) architecture formerly codenamed Sandy Bridge ia32=G9, x64=E9 */
+ mask = AVX_MSK;
+ *index = LIB_AVX;
+ } else
+ if( ippCPUID_SSE42 == ( *cpuFeatures & ippCPUID_SSE42 )){ /* Intel(R) architecture formerly codenamed Nehalem or Intel(R) architecture formerly codenamed Westmer = Intel(R) architecture formerly codenamed Penryn + Intel(R) SSE4.2 + ?Intel(R) instruction PCLMULQDQ + ?(Intel(R) AES New Instructions) + ?(Intel(R) Secure Hash Algorithm Extensions) */
+ mask = SSE42_MSK; /* or new Intel Atom(R) processor formerly codenamed Silvermont */
+ *index = LIB_SSE42;
+ } else
+ if( ippCPUID_SSE41 == ( *cpuFeatures & ippCPUID_SSE41 )){ /* Intel(R) architecture formerly codenamed Penryn ia32=P8, x64=Y8 */
+ mask = SSE41_MSK;
+ *index = LIB_SSE41;
+ } else
+ if( ippCPUID_MOVBE == ( *cpuFeatures & ippCPUID_MOVBE )) { /* Intel Atom(R) processor formerly codenamed Silverthorne ia32=S8, x64=N8 */
+ mask = ATOM_MSK;
+ *index = LIB_ATOM;
+ } else
+ if( ippCPUID_SSSE3 == ( *cpuFeatures & ippCPUID_SSSE3 )) { /* Intel(R) architecture formerly codenamed Merom ia32=V8, x64=U8 (letters etymology is unknown) */
+ mask = SSSE3_MSK;
+ *index = LIB_SSSE3;
+ } else
+ if( ippCPUID_SSE3 == ( *cpuFeatures & ippCPUID_SSE3 )) { /* Intel(R) architecture formerly codenamed Prescott ia32=W7, x64=M7 */
+ mask = SSE3_MSK;
+ *index = LIB_SSE3;
+ } else
+ if( ippCPUID_SSE2 == ( *cpuFeatures & ippCPUID_SSE2 )) { /* Intel(R) architecture formerly codenamed Willamette ia32=W7, x64=PX */
+ mask = SSE2_MSK;
+ *index = LIB_SSE2;
+ } else
+ if( ippCPUID_SSE == ( *cpuFeatures & ippCPUID_SSE )) { /* Intel(R) Pentium(R) processor III ia32=PX only */
+ mask = SSE_MSK;
+ *index = LIB_SSE;
+#if (defined( _WIN32E ) || defined( linux32e ) || defined( OSXEM64T )) && !(defined( _ARCH_LRB2 ))
+ ownStatus = ippStsNotSupportedCpu; /* the lowest CPU supported by Intel(R) Integrated Performance Primitives (Intel(R) IPP) must at least support Intel(R) SSE2 for x64 */
+#endif
+ } else
+ if( ippCPUID_MMX >= ( *cpuFeatures & ippCPUID_MMX )) { /* not supported, PX dispatched */
+ mask = MMX_MSK;
+ *index = LIB_MMX;
+ ownStatus = ippStsNotSupportedCpu; /* the lowest CPU supported by Intel(R) IPP must at least support Intel(R) SSE for ia32 or Intel(R) SSE2 for x64 */
+ }
+#if defined ( _IPP_QUARK)
+ else {
+ mask = PX_MSK;
+ *index = LIB_PX;
+ ownStatus = ippStsNoErr; /* the lowest CPU supported by Intel(R) IPP must at least support Intel(R) SSE for ia32 or Intel(R) SSE2 for x64 */
+ }
+#endif
+
+ if(( mask != ( *cpuFeatures & mask ))&&( ownStatus == ippStsNoErr ))
+ ownStatus = ippStsFeaturesCombination; /* warning if combination of features is incomplete */
+ *cpuFeatures |= mask;
+ return ownStatus;
+}
+
+#ifdef _PCS
+
+extern IppStatus (IPP_STDCALL *pcpSetCpuFeatures)( Ipp64u cpuFeatures );
+extern IppStatus (IPP_STDCALL *pcpSetNumThreads)( int numThr );
+extern IppStatus (IPP_STDCALL *pcpGetNumThreads)( int* pNumThr );
+
+IPPFUN( IppStatus, ippcpSetNumThreads, ( int numThr ))
+{
+ IppStatus status = ippStsNoErr;
+
+ if (pcpSetNumThreads != 0)
+ {
+ status = pcpSetNumThreads(numThr);
+ if (status == ippStsNoErr)
+ {
+ cpthreads_omp_of_n_ipp = numThr;
+ }
+ }
+ return status;
+}
+
+IPPFUN( IppStatus, ippcpGetNumThreads, (int* pNumThr) )
+{
+ IppStatus status = ippStsNoErr;
+
+ IPP_BAD_PTR1_RET( pNumThr )
+
+ if (pcpGetNumThreads != 0)
+ {
+ status = pcpGetNumThreads(pNumThr);
+ }
+ return status;
+}
+#else
+
+
+IPPFUN( IppStatus, ippcpSetNumThreads, ( int numThr ))
+{
+ IppStatus status = ippStsNoErr;
+#if defined( _OPENMP )
+ IPP_BAD_SIZE_RET( numThr )
+ cpthreads_omp_of_n_ipp = numThr;
+ status = ippStsNoErr;
+#else
+ UNREFERENCED_PARAMETER(numThr);
+ status = ippStsNoOperation;
+#endif
+ return status;
+}
+
+IPPFUN( IppStatus, ippcpGetNumThreads, (int* pNumThr) )
+{
+ IppStatus status = ippStsNoErr;
+ IPP_BAD_PTR1_RET( pNumThr )
+
+#if defined( _OPENMP )
+ *pNumThr = cpthreads_omp_of_n_ipp;
+ status = ippStsNoErr;
+#else
+ *pNumThr = 1;
+ status = ippStsNoOperation;
+#endif
+ return status;
+}
+
+#endif /* #ifdef _PCS */
+
+#ifdef _IPP_DYNAMIC
+
+typedef IppStatus (IPP_STDCALL *DYN_RELOAD)( int );
+static DYN_RELOAD IppDispatcher; /* ippCP only */
+static int currentCpu = -1; /* control for disabling the same DLL re-loading */
+
+void owncpRegisterLib( DYN_RELOAD reload )
+{
+ pcpSetCpuFeatures = 0;
+ pcpSetNumThreads = 0;
+ pcpGetNumThreads = 0;
+
+ IppDispatcher = reload; /* function DynReload() that is defined in ippmain.gen - */
+ return; /* therefore in each domain there is own DynReload() function */
+}
+
+void owncpUnregisterLib( void )
+{
+ IppDispatcher = 0;
+ currentCpu = -1;
+
+ pcpSetCpuFeatures = 0;
+ pcpSetNumThreads = 0;
+ pcpGetNumThreads = 0;
+
+ return;
+}
+
+IPPFUN( IppStatus, ippcpSetCpuFeatures,( Ipp64u cpuFeatures ))
+{
+ IppStatus status, ownStatus;
+ int index = 0;
+
+ ownStatus = owncpSetCpuFeaturesAndIdx( cpuFeatures, &index );
+ if(( IppDispatcher )&&( currentCpu != index )) {
+ status = IppDispatcher( index );
+ currentCpu = index;
+ } else
+ status = ippStsNoErr;
+
+#ifdef _PCS
+ if (pcpSetCpuFeatures != 0 && status >= ippStsNoErr)
+ {
+ /* Pass down features to Waterfall dll */
+ status = pcpSetCpuFeatures(cpuFeatures);
+ }
+ if (pcpSetNumThreads != 0 && status >= ippStsNoErr)
+ {
+ /* Pass down features to Waterfall dll */
+ status = pcpSetNumThreads(cpthreads_omp_of_n_ipp);
+ }
+#endif
+
+ if( status != ippStsNoErr && status != ippStsNoOperation)
+ return status;
+ else
+ return ownStatus;
+}
+
+IPPFUN( IppStatus, ippcpInit,( void ))
+{
+ int index = 0;
+ IppStatus status, statusf, statusi;
+ Ipp64u cpuFeatures;
+
+ statusf = ippcpGetCpuFeatures( &cpuFeatures );
+ statusi = owncpSetCpuFeaturesAndIdx( cpuFeatures, &index ); /* ownSetFeatures instead of ippSetFeatures because need unconditional initialization, */
+ if( IppDispatcher ) status = IppDispatcher( index ); /* call DynReload() function for each domain */
+ else status = ippStsNoErr;
+ currentCpu = index;
+ if( ippStsNoErr != statusf ) return statusf;
+ if( ippStsNoErr != statusi ) return statusi;
+ if( ippStsNoErr != status ) return status;
+ return ippStsNoErr;
+}
+
+
+#else /* _IPP_DYNAMIC */
+
+IPPFUN( IppStatus, ippcpInit,( void ))
+{
+ Ipp64u cpuFeatures;
+
+#if defined( _OPENMP )
+ ippcpSetNumThreads( IPP_MIN( omp_get_num_procs(), omp_get_max_threads()));
+#endif
+ ippcpGetCpuFeatures( &cpuFeatures );
+ return ippcpSetCpuFeatures( cpuFeatures );
+}
+
+
+IPPFUN( IppStatus, ippcpSetCpuFeatures,( Ipp64u cpuFeatures ))
+{
+ IppStatus ownStatus;
+ int index = 0;
+
+#if defined( _OPENMP )
+ ippcpSetNumThreads( IPP_MIN( omp_get_num_procs(), omp_get_max_threads()));
+#endif
+ ownStatus = owncpSetCpuFeaturesAndIdx( cpuFeatures, &index );
+ ippcpJumpIndexForMergedLibs = index;
+ cpFeaturesMask = cpuFeatures;
+ return ownStatus;
+}
+
+#endif
+
+IppStatus owncpSetCpuFeaturesAndIdx( Ipp64u cpuFeatures, int* index )
+{
+ Ipp64u tmp;
+ IppStatus tmpStatus;
+ *index = 0;
+
+ if( ippCPUID_NOCHECK & cpuFeatures ){
+ // if NOCHECK is set - static variable cpFeatures is initialized unconditionally and real CPU features from CPUID are ignored;
+ // the one who uses this method of initialization must understand what and why it does and the possible unpredictable consequences.
+ // the only one known purpose for this approach - environments where CPUID instruction is disabled (for example Intel(R) Software Guard Extensions).
+ cpuFeatures &= ( IPP_MAX_64U ^ ippCPUID_NOCHECK );
+ cpFeatures = cpuFeatures;
+ } else
+// if( 0 == cpFeatures ) //do cpFeatures restore unconditionally - to protect from possible previous NOCHECK
+ {
+ // if library has not been initialized yet
+ cpGetFeatures( &tmp );
+ }
+ tmpStatus = owncpFeaturesToIdx( &cpuFeatures, index );
+ cpFeaturesMask = cpuFeatures;
+
+ return tmpStatus;
+}
+
+static struct {
+ int sts;
+ const char *msg;
+} ippcpMsg[] = {
+/* ippStatus */
+/* -9999 */ ippStsCpuNotSupportedErr, "ippStsCpuNotSupportedErr: The target CPU is not supported",
+/* -9702 */ MSG_NO_SHARED, "No shared libraries were found in the Waterfall procedure",
+/* -9701 */ MSG_NO_DLL, "No DLLs were found in the Waterfall procedure",
+/* -9700 */ MSG_LOAD_DLL_ERR, "Error at loading of %s library",
+/* -1016 */ ippStsQuadraticNonResidueErr, "ippStsQuadraticNonResidueErr: SQRT operation on quadratic non-residue value",
+/* -1015 */ ippStsPointAtInfinity, "ippStsPointAtInfinity: Point at infinity is detected",
+/* -1014 */ ippStsOFBSizeErr, "ippStsOFBSizeErr: Incorrect value for crypto OFB block size",
+/* -1013 */ ippStsIncompleteContextErr, "ippStsIncompleteContextErr: Crypto: set up of context is not complete",
+/* -1012 */ ippStsCTRSizeErr, "ippStsCTRSizeErr: Incorrect value for crypto CTR block size",
+/* -1011 */ ippStsEphemeralKeyErr, "ippStsEphemeralKeyErr: ECC: Invalid ephemeral key",
+/* -1010 */ ippStsMessageErr, "ippStsMessageErr: ECC: Invalid message digest",
+/* -1009 */ ippStsShareKeyErr, "ippStsShareKeyErr: ECC: Invalid share key",
+/* -1008 */ ippStsIvalidPrivateKey, "ippStsIvalidPrivateKey ECC: Invalid private key",
+/* -1007 */ ippStsOutOfECErr, "ippStsOutOfECErr: ECC: Point out of EC",
+/* -1006 */ ippStsECCInvalidFlagErr, "ippStsECCInvalidFlagErr: ECC: Invalid Flag",
+/* -1005 */ ippStsUnderRunErr, "ippStsUnderRunErr: Error in data under run",
+/* -1004 */ ippStsPaddingErr, "ippStsPaddingErr: Detected padding error indicates the possible data corruption",
+/* -1003 */ ippStsCFBSizeErr, "ippStsCFBSizeErr: Incorrect value for crypto CFB block size",
+/* -1002 */ ippStsPaddingSchemeErr, "ippStsPaddingSchemeErr: Invalid padding scheme",
+/* -1001 */ ippStsBadModulusErr, "ippStsBadModulusErr: Bad modulus caused a failure in module inversion",
+/* -216 */ ippStsUnknownStatusCodeErr, "ippStsUnknownStatusCodeErr: Unknown status code",
+/* -221 */ ippStsLoadDynErr, "ippStsLoadDynErr: Error when loading the dynamic library",
+/* -15 */ ippStsLengthErr, "ippStsLengthErr: Incorrect value for string length",
+/* -14 */ ippStsNotSupportedModeErr, "ippStsNotSupportedModeErr: The requested mode is currently not supported",
+/* -13 */ ippStsContextMatchErr, "ippStsContextMatchErr: Context parameter does not match the operation",
+/* -12 */ ippStsScaleRangeErr, "ippStsScaleRangeErr: Scale bounds are out of range",
+/* -11 */ ippStsOutOfRangeErr, "ippStsOutOfRangeErr: Argument is out of range, or point is outside the image",
+/* -10 */ ippStsDivByZeroErr, "ippStsDivByZeroErr: An attempt to divide by zero",
+/* -9 */ ippStsMemAllocErr, "ippStsMemAllocErr: Memory allocated for the operation is not enough",
+/* -8 */ ippStsNullPtrErr, "ippStsNullPtrErr: Null pointer error",
+/* -7 */ ippStsRangeErr, "ippStsRangeErr: Incorrect values for bounds: the lower bound is greater than the upper bound",
+/* -6 */ ippStsSizeErr, "ippStsSizeErr: Incorrect value for data size",
+/* -5 */ ippStsBadArgErr, "ippStsBadArgErr: Incorrect arg/param of the function",
+/* -4 */ ippStsNoMemErr, "ippStsNoMemErr: Not enough memory for the operation",
+/* -2 */ ippStsErr, "ippStsErr: Unknown/unspecified error, -2",
+/* 0 */ ippStsNoErr, "ippStsNoErr: No errors",
+/* 1 */ ippStsNoOperation, "ippStsNoOperation: No operation has been executed",
+/* 2 */ ippStsDivByZero, "ippStsDivByZero: Zero value(s) for the divisor in the Div function",
+/* 25 */ ippStsInsufficientEntropy, "ippStsInsufficientEntropy: Generation of the prime/key failed due to insufficient entropy in the random seed and stimulus bit string",
+/* 36 */ ippStsNotSupportedCpu, "The CPU is not supported",
+/* 36 */ ippStsFeaturesCombination, "Wrong combination of features",
+};
+
+/* /////////////////////////////////////////////////////////////////////////////
+// Name: ippcpGetStatusString
+// Purpose: transformation of a code of a status Intel(R) IPP to string
+// Returns:
+// Parameters:
+// StsCode Intel(R) IPP status code
+//
+// Notes: not necessary to release the returned string
+*/
+IPPFUN( const char*, ippcpGetStatusString, ( IppStatus StsCode ) )
+{
+ unsigned int i;
+ for( i=0; i<IPP_COUNT_OF( ippcpMsg ); i++ ) {
+ if( StsCode == ippcpMsg[i].sts ) {
+ return ippcpMsg[i].msg;
+ }
+ }
+ return ippcpGetStatusString( ippStsUnknownStatusCodeErr );
+}
+
+extern Ipp64u IPP_CDECL cp_get_pentium_counter (void);
+
+/* /////////////////////////////////////////////////////////////////////////////
+// Name: ippcpGetCpuClocks
+// Purpose: time stamp counter (TSC) register reading
+// Returns: TSC value
+//
+// Note: An hardware exception is possible if TSC reading is not supported by
+// the current chipset
+*/
+IPPFUN( Ipp64u, ippcpGetCpuClocks, (void) )
+{
+ return (Ipp64u)cp_get_pentium_counter();
+}
+
+#endif /* _IPP_DATA */
diff --git a/ext/ipp/sources/ippcp/exports.linux.lib-export b/ext/ipp/sources/ippcp/exports.linux.lib-export
new file mode 100644
index 0000000..d7ec12f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/exports.linux.lib-export
@@ -0,0 +1,1021 @@
+EXTERN (ippcpGetLibVersion)
+EXTERN (ippcpInit)
+EXTERN (cpGetReg)
+EXTERN (cpStartTscp)
+EXTERN (cpStopTscp)
+EXTERN (cpStartTsc)
+EXTERN (cpStopTsc)
+EXTERN (cpGetCacheSize)
+EXTERN (ippcpSetCpuFeatures)
+EXTERN (ippcpGetCpuFeatures)
+EXTERN (ippcpGetCpuClocks)
+EXTERN (ippcpSetNumThreads)
+EXTERN (ippcpGetNumThreads)
+EXTERN (ippcpGetEnabledCpuFeatures)
+EXTERN (ippcpGetEnabledNumThreads)
+EXTERN (ippcpGetStatusString)
+EXTERN (ippsDESGetSize)
+EXTERN (ippsDESInit)
+EXTERN (ippsDESPack)
+EXTERN (ippsDESUnpack)
+EXTERN (ippsTDESEncryptECB)
+EXTERN (ippsTDESDecryptECB)
+EXTERN (ippsTDESEncryptCBC)
+EXTERN (ippsTDESDecryptCBC)
+EXTERN (ippsTDESEncryptCFB)
+EXTERN (ippsTDESDecryptCFB)
+EXTERN (ippsTDESEncryptOFB)
+EXTERN (ippsTDESDecryptOFB)
+EXTERN (ippsTDESEncryptCTR)
+EXTERN (ippsTDESDecryptCTR)
+EXTERN (ippsAESGetSize)
+EXTERN (ippsAESInit)
+EXTERN (ippsAESSetKey)
+EXTERN (ippsAESPack)
+EXTERN (ippsAESUnpack)
+EXTERN (ippsAESEncryptECB)
+EXTERN (ippsAESDecryptECB)
+EXTERN (ippsAESEncryptCBC)
+EXTERN (ippsAESEncryptCBC_CS1)
+EXTERN (ippsAESEncryptCBC_CS2)
+EXTERN (ippsAESEncryptCBC_CS3)
+EXTERN (ippsAESDecryptCBC)
+EXTERN (ippsAESDecryptCBC_CS1)
+EXTERN (ippsAESDecryptCBC_CS2)
+EXTERN (ippsAESDecryptCBC_CS3)
+EXTERN (ippsAESEncryptCFB)
+EXTERN (ippsAESDecryptCFB)
+EXTERN (ippsAESEncryptOFB)
+EXTERN (ippsAESDecryptOFB)
+EXTERN (ippsAESEncryptCTR)
+EXTERN (ippsAESDecryptCTR)
+EXTERN (ippsAESEncryptXTS_Direct)
+EXTERN (ippsAESDecryptXTS_Direct)
+EXTERN (ippsSMS4GetSize)
+EXTERN (ippsSMS4Init)
+EXTERN (ippsSMS4SetKey)
+EXTERN (ippsSMS4EncryptECB)
+EXTERN (ippsSMS4DecryptECB)
+EXTERN (ippsSMS4EncryptCBC)
+EXTERN (ippsSMS4EncryptCBC_CS1)
+EXTERN (ippsSMS4EncryptCBC_CS2)
+EXTERN (ippsSMS4EncryptCBC_CS3)
+EXTERN (ippsSMS4DecryptCBC)
+EXTERN (ippsSMS4DecryptCBC_CS1)
+EXTERN (ippsSMS4DecryptCBC_CS2)
+EXTERN (ippsSMS4DecryptCBC_CS3)
+EXTERN (ippsSMS4EncryptCFB)
+EXTERN (ippsSMS4DecryptCFB)
+EXTERN (ippsSMS4EncryptOFB)
+EXTERN (ippsSMS4DecryptOFB)
+EXTERN (ippsSMS4EncryptCTR)
+EXTERN (ippsSMS4DecryptCTR)
+EXTERN (ippsSMS4_CCMGetSize)
+EXTERN (ippsSMS4_CCMInit)
+EXTERN (ippsSMS4_CCMMessageLen)
+EXTERN (ippsSMS4_CCMTagLen)
+EXTERN (ippsSMS4_CCMStart)
+EXTERN (ippsSMS4_CCMEncrypt)
+EXTERN (ippsSMS4_CCMDecrypt)
+EXTERN (ippsSMS4_CCMGetTag)
+EXTERN (ippsAES_CCMGetSize)
+EXTERN (ippsAES_CCMInit)
+EXTERN (ippsAES_CCMMessageLen)
+EXTERN (ippsAES_CCMTagLen)
+EXTERN (ippsAES_CCMStart)
+EXTERN (ippsAES_CCMEncrypt)
+EXTERN (ippsAES_CCMDecrypt)
+EXTERN (ippsAES_CCMGetTag)
+EXTERN (ippsAES_GCMGetSize)
+EXTERN (ippsAES_GCMInit)
+EXTERN (ippsAES_GCMReset)
+EXTERN (ippsAES_GCMProcessIV)
+EXTERN (ippsAES_GCMProcessAAD)
+EXTERN (ippsAES_GCMStart)
+EXTERN (ippsAES_GCMEncrypt)
+EXTERN (ippsAES_GCMDecrypt)
+EXTERN (ippsAES_GCMGetTag)
+EXTERN (ippsAES_XTSGetSize)
+EXTERN (ippsAES_XTSInit)
+EXTERN (ippsAES_XTSEncrypt)
+EXTERN (ippsAES_XTSDecrypt)
+EXTERN (ippsAES_S2V_CMAC)
+EXTERN (ippsAES_SIVEncrypt)
+EXTERN (ippsAES_SIVDecrypt)
+EXTERN (ippsAES_CMACGetSize)
+EXTERN (ippsAES_CMACInit)
+EXTERN (ippsAES_CMACUpdate)
+EXTERN (ippsAES_CMACFinal)
+EXTERN (ippsAES_CMACGetTag)
+EXTERN (ippsARCFourCheckKey)
+EXTERN (ippsARCFourGetSize)
+EXTERN (ippsARCFourInit)
+EXTERN (ippsARCFourReset)
+EXTERN (ippsARCFourPack)
+EXTERN (ippsARCFourUnpack)
+EXTERN (ippsARCFourEncrypt)
+EXTERN (ippsARCFourDecrypt)
+EXTERN (ippsSHA1GetSize)
+EXTERN (ippsSHA1Init)
+EXTERN (ippsSHA1Duplicate)
+EXTERN (ippsSHA1Pack)
+EXTERN (ippsSHA1Unpack)
+EXTERN (ippsSHA1Update)
+EXTERN (ippsSHA1GetTag)
+EXTERN (ippsSHA1Final)
+EXTERN (ippsSHA1MessageDigest)
+EXTERN (ippsSHA224GetSize)
+EXTERN (ippsSHA224Init)
+EXTERN (ippsSHA224Duplicate)
+EXTERN (ippsSHA224Pack)
+EXTERN (ippsSHA224Unpack)
+EXTERN (ippsSHA224Update)
+EXTERN (ippsSHA224GetTag)
+EXTERN (ippsSHA224Final)
+EXTERN (ippsSHA224MessageDigest)
+EXTERN (ippsSHA256GetSize)
+EXTERN (ippsSHA256Init)
+EXTERN (ippsSHA256Duplicate)
+EXTERN (ippsSHA256Pack)
+EXTERN (ippsSHA256Unpack)
+EXTERN (ippsSHA256Update)
+EXTERN (ippsSHA256GetTag)
+EXTERN (ippsSHA256Final)
+EXTERN (ippsSHA256MessageDigest)
+EXTERN (ippsSHA384GetSize)
+EXTERN (ippsSHA384Init)
+EXTERN (ippsSHA384Duplicate)
+EXTERN (ippsSHA384Pack)
+EXTERN (ippsSHA384Unpack)
+EXTERN (ippsSHA384Update)
+EXTERN (ippsSHA384GetTag)
+EXTERN (ippsSHA384Final)
+EXTERN (ippsSHA384MessageDigest)
+EXTERN (ippsSHA512GetSize)
+EXTERN (ippsSHA512Init)
+EXTERN (ippsSHA512Duplicate)
+EXTERN (ippsSHA512Pack)
+EXTERN (ippsSHA512Unpack)
+EXTERN (ippsSHA512Update)
+EXTERN (ippsSHA512GetTag)
+EXTERN (ippsSHA512Final)
+EXTERN (ippsSHA512MessageDigest)
+EXTERN (ippsMD5GetSize)
+EXTERN (ippsMD5Init)
+EXTERN (ippsMD5Duplicate)
+EXTERN (ippsMD5Pack)
+EXTERN (ippsMD5Unpack)
+EXTERN (ippsMD5Update)
+EXTERN (ippsMD5GetTag)
+EXTERN (ippsMD5Final)
+EXTERN (ippsMD5MessageDigest)
+EXTERN (ippsSM3GetSize)
+EXTERN (ippsSM3Init)
+EXTERN (ippsSM3Duplicate)
+EXTERN (ippsSM3Pack)
+EXTERN (ippsSM3Unpack)
+EXTERN (ippsSM3Update)
+EXTERN (ippsSM3GetTag)
+EXTERN (ippsSM3Final)
+EXTERN (ippsSM3MessageDigest)
+EXTERN (ippsHashGetSize)
+EXTERN (ippsHashInit)
+EXTERN (ippsHashPack)
+EXTERN (ippsHashUnpack)
+EXTERN (ippsHashDuplicate)
+EXTERN (ippsHashUpdate)
+EXTERN (ippsHashGetTag)
+EXTERN (ippsHashFinal)
+EXTERN (ippsHashMessage)
+EXTERN (ippsHashMethod_MD5)
+EXTERN (ippsHashMethod_SM3)
+EXTERN (ippsHashMethod_SHA1)
+EXTERN (ippsHashMethod_SHA1_NI)
+EXTERN (ippsHashMethod_SHA1_TT)
+EXTERN (ippsHashMethod_SHA256)
+EXTERN (ippsHashMethod_SHA256_NI)
+EXTERN (ippsHashMethod_SHA256_TT)
+EXTERN (ippsHashMethod_SHA224)
+EXTERN (ippsHashMethod_SHA224_NI)
+EXTERN (ippsHashMethod_SHA224_TT)
+EXTERN (ippsHashMethod_SHA512)
+EXTERN (ippsHashMethod_SHA384)
+EXTERN (ippsHashMethod_SHA512_256)
+EXTERN (ippsHashMethod_SHA512_224)
+EXTERN (ippsHashGetSize_rmf)
+EXTERN (ippsHashInit_rmf)
+EXTERN (ippsHashPack_rmf)
+EXTERN (ippsHashUnpack_rmf)
+EXTERN (ippsHashDuplicate_rmf)
+EXTERN (ippsHashUpdate_rmf)
+EXTERN (ippsHashGetTag_rmf)
+EXTERN (ippsHashFinal_rmf)
+EXTERN (ippsHashMessage_rmf)
+EXTERN (ippsMGF)
+EXTERN (ippsMGF1_rmf)
+EXTERN (ippsMGF2_rmf)
+EXTERN (ippsHMAC_GetSize)
+EXTERN (ippsHMAC_Init)
+EXTERN (ippsHMAC_Pack)
+EXTERN (ippsHMAC_Unpack)
+EXTERN (ippsHMAC_Duplicate)
+EXTERN (ippsHMAC_Update)
+EXTERN (ippsHMAC_Final)
+EXTERN (ippsHMAC_GetTag)
+EXTERN (ippsHMAC_Message)
+EXTERN (ippsHMACGetSize_rmf)
+EXTERN (ippsHMACInit_rmf)
+EXTERN (ippsHMACPack_rmf)
+EXTERN (ippsHMACUnpack_rmf)
+EXTERN (ippsHMACDuplicate_rmf)
+EXTERN (ippsHMACUpdate_rmf)
+EXTERN (ippsHMACFinal_rmf)
+EXTERN (ippsHMACGetTag_rmf)
+EXTERN (ippsHMACMessage_rmf)
+EXTERN (ippsBigNumGetSize)
+EXTERN (ippsBigNumInit)
+EXTERN (ippsCmpZero_BN)
+EXTERN (ippsCmp_BN)
+EXTERN (ippsGetSize_BN)
+EXTERN (ippsSet_BN)
+EXTERN (ippsGet_BN)
+EXTERN (ippsRef_BN)
+EXTERN (ippsExtGet_BN)
+EXTERN (ippsAdd_BN)
+EXTERN (ippsSub_BN)
+EXTERN (ippsMul_BN)
+EXTERN (ippsMAC_BN_I)
+EXTERN (ippsDiv_BN)
+EXTERN (ippsMod_BN)
+EXTERN (ippsGcd_BN)
+EXTERN (ippsModInv_BN)
+EXTERN (ippsSetOctString_BN)
+EXTERN (ippsGetOctString_BN)
+EXTERN (ippsMontGetSize)
+EXTERN (ippsMontInit)
+EXTERN (ippsMontSet)
+EXTERN (ippsMontGet)
+EXTERN (ippsMontForm)
+EXTERN (ippsMontMul)
+EXTERN (ippsMontExp)
+EXTERN (ippsPRNGGetSize)
+EXTERN (ippsPRNGInit)
+EXTERN (ippsPRNGSetModulus)
+EXTERN (ippsPRNGSetH0)
+EXTERN (ippsPRNGSetAugment)
+EXTERN (ippsPRNGSetSeed)
+EXTERN (ippsPRNGGetSeed)
+EXTERN (ippsPRNGen)
+EXTERN (ippsPRNGen_BN)
+EXTERN (ippsPRNGenRDRAND)
+EXTERN (ippsPRNGenRDRAND_BN)
+EXTERN (ippsTRNGenRDSEED)
+EXTERN (ippsTRNGenRDSEED_BN)
+EXTERN (ippsPrimeGetSize)
+EXTERN (ippsPrimeInit)
+EXTERN (ippsPrimeGen)
+EXTERN (ippsPrimeTest)
+EXTERN (ippsPrimeGen_BN)
+EXTERN (ippsPrimeTest_BN)
+EXTERN (ippsPrimeGet)
+EXTERN (ippsPrimeGet_BN)
+EXTERN (ippsPrimeSet)
+EXTERN (ippsPrimeSet_BN)
+EXTERN (ippsRSA_GetSizePublicKey)
+EXTERN (ippsRSA_InitPublicKey)
+EXTERN (ippsRSA_SetPublicKey)
+EXTERN (ippsRSA_GetPublicKey)
+EXTERN (ippsRSA_GetSizePrivateKeyType1)
+EXTERN (ippsRSA_InitPrivateKeyType1)
+EXTERN (ippsRSA_SetPrivateKeyType1)
+EXTERN (ippsRSA_GetPrivateKeyType1)
+EXTERN (ippsRSA_GetSizePrivateKeyType2)
+EXTERN (ippsRSA_InitPrivateKeyType2)
+EXTERN (ippsRSA_SetPrivateKeyType2)
+EXTERN (ippsRSA_GetPrivateKeyType2)
+EXTERN (ippsRSA_GetBufferSizePublicKey)
+EXTERN (ippsRSA_GetBufferSizePrivateKey)
+EXTERN (ippsRSA_Encrypt)
+EXTERN (ippsRSA_Decrypt)
+EXTERN (ippsRSA_GenerateKeys)
+EXTERN (ippsRSA_ValidateKeys)
+EXTERN (ippsRSAEncrypt_OAEP)
+EXTERN (ippsRSADecrypt_OAEP)
+EXTERN (ippsRSAEncrypt_OAEP_rmf)
+EXTERN (ippsRSADecrypt_OAEP_rmf)
+EXTERN (ippsRSAEncrypt_PKCSv15)
+EXTERN (ippsRSADecrypt_PKCSv15)
+EXTERN (ippsRSASign_PSS)
+EXTERN (ippsRSAVerify_PSS)
+EXTERN (ippsRSASign_PSS_rmf)
+EXTERN (ippsRSAVerify_PSS_rmf)
+EXTERN (ippsRSASign_PKCS1v15)
+EXTERN (ippsRSAVerify_PKCS1v15)
+EXTERN (ippsRSASign_PKCS1v15_rmf)
+EXTERN (ippsRSAVerify_PKCS1v15_rmf)
+EXTERN (ippsDLGetResultString)
+EXTERN (ippsDLPGetSize)
+EXTERN (ippsDLPInit)
+EXTERN (ippsDLPPack)
+EXTERN (ippsDLPUnpack)
+EXTERN (ippsDLPSet)
+EXTERN (ippsDLPGet)
+EXTERN (ippsDLPSetDP)
+EXTERN (ippsDLPGetDP)
+EXTERN (ippsDLPGenKeyPair)
+EXTERN (ippsDLPPublicKey)
+EXTERN (ippsDLPValidateKeyPair)
+EXTERN (ippsDLPSetKeyPair)
+EXTERN (ippsDLPSignDSA)
+EXTERN (ippsDLPVerifyDSA)
+EXTERN (ippsDLPSharedSecretDH)
+EXTERN (ippsDLPGenerateDSA)
+EXTERN (ippsDLPValidateDSA)
+EXTERN (ippsDLPGenerateDH)
+EXTERN (ippsDLPValidateDH)
+EXTERN (ippsECCGetResultString)
+EXTERN (ippsECCPGetSize)
+EXTERN (ippsECCPGetSizeStd128r1)
+EXTERN (ippsECCPGetSizeStd128r2)
+EXTERN (ippsECCPGetSizeStd192r1)
+EXTERN (ippsECCPGetSizeStd224r1)
+EXTERN (ippsECCPGetSizeStd256r1)
+EXTERN (ippsECCPGetSizeStd384r1)
+EXTERN (ippsECCPGetSizeStd521r1)
+EXTERN (ippsECCPGetSizeStdSM2)
+EXTERN (ippsECCPInit)
+EXTERN (ippsECCPInitStd128r1)
+EXTERN (ippsECCPInitStd128r2)
+EXTERN (ippsECCPInitStd192r1)
+EXTERN (ippsECCPInitStd224r1)
+EXTERN (ippsECCPInitStd256r1)
+EXTERN (ippsECCPInitStd384r1)
+EXTERN (ippsECCPInitStd521r1)
+EXTERN (ippsECCPInitStdSM2)
+EXTERN (ippsECCPSet)
+EXTERN (ippsECCPSetStd)
+EXTERN (ippsECCPSetStd128r1)
+EXTERN (ippsECCPSetStd128r2)
+EXTERN (ippsECCPSetStd192r1)
+EXTERN (ippsECCPSetStd224r1)
+EXTERN (ippsECCPSetStd256r1)
+EXTERN (ippsECCPSetStd384r1)
+EXTERN (ippsECCPSetStd521r1)
+EXTERN (ippsECCPSetStdSM2)
+EXTERN (ippsECCPBindGxyTblStd192r1)
+EXTERN (ippsECCPBindGxyTblStd224r1)
+EXTERN (ippsECCPBindGxyTblStd256r1)
+EXTERN (ippsECCPBindGxyTblStd384r1)
+EXTERN (ippsECCPBindGxyTblStd521r1)
+EXTERN (ippsECCPBindGxyTblStdSM2)
+EXTERN (ippsECCPGet)
+EXTERN (ippsECCPGetOrderBitSize)
+EXTERN (ippsECCPValidate)
+EXTERN (ippsECCPPointGetSize)
+EXTERN (ippsECCPPointInit)
+EXTERN (ippsECCPSetPoint)
+EXTERN (ippsECCPSetPointAtInfinity)
+EXTERN (ippsECCPGetPoint)
+EXTERN (ippsECCPCheckPoint)
+EXTERN (ippsECCPComparePoint)
+EXTERN (ippsECCPNegativePoint)
+EXTERN (ippsECCPAddPoint)
+EXTERN (ippsECCPMulPointScalar)
+EXTERN (ippsECCPGenKeyPair)
+EXTERN (ippsECCPPublicKey)
+EXTERN (ippsECCPValidateKeyPair)
+EXTERN (ippsECCPSetKeyPair)
+EXTERN (ippsECCPSharedSecretDH)
+EXTERN (ippsECCPSharedSecretDHC)
+EXTERN (ippsECCPSignDSA)
+EXTERN (ippsECCPVerifyDSA)
+EXTERN (ippsECCPSignNR)
+EXTERN (ippsECCPVerifyNR)
+EXTERN (ippsECCPSignSM2)
+EXTERN (ippsECCPVerifySM2)
+EXTERN (ippsGFpGetSize)
+EXTERN (ippsGFpInitArbitrary)
+EXTERN (ippsGFpInitFixed)
+EXTERN (ippsGFpInit)
+EXTERN (ippsGFpMethod_p192r1)
+EXTERN (ippsGFpMethod_p224r1)
+EXTERN (ippsGFpMethod_p256r1)
+EXTERN (ippsGFpMethod_p384r1)
+EXTERN (ippsGFpMethod_p521r1)
+EXTERN (ippsGFpMethod_p256sm2)
+EXTERN (ippsGFpMethod_p256bn)
+EXTERN (ippsGFpMethod_p256)
+EXTERN (ippsGFpMethod_pArb)
+EXTERN (ippsGFpxGetSize)
+EXTERN (ippsGFpxInit)
+EXTERN (ippsGFpxInitBinomial)
+EXTERN (ippsGFpxMethod_binom2_epid2)
+EXTERN (ippsGFpxMethod_binom3_epid2)
+EXTERN (ippsGFpxMethod_binom2)
+EXTERN (ippsGFpxMethod_binom3)
+EXTERN (ippsGFpxMethod_binom)
+EXTERN (ippsGFpxMethod_com)
+EXTERN (ippsGFpScratchBufferSize)
+EXTERN (ippsGFpElementGetSize)
+EXTERN (ippsGFpElementInit)
+EXTERN (ippsGFpSetElement)
+EXTERN (ippsGFpSetElementRegular)
+EXTERN (ippsGFpSetElementOctString)
+EXTERN (ippsGFpSetElementRandom)
+EXTERN (ippsGFpSetElementHash)
+EXTERN (ippsGFpSetElementHash_rmf)
+EXTERN (ippsGFpCpyElement)
+EXTERN (ippsGFpGetElement)
+EXTERN (ippsGFpGetElementOctString)
+EXTERN (ippsGFpCmpElement)
+EXTERN (ippsGFpIsZeroElement)
+EXTERN (ippsGFpIsUnityElement)
+EXTERN (ippsGFpConj)
+EXTERN (ippsGFpNeg)
+EXTERN (ippsGFpInv)
+EXTERN (ippsGFpSqrt)
+EXTERN (ippsGFpSqr)
+EXTERN (ippsGFpAdd)
+EXTERN (ippsGFpSub)
+EXTERN (ippsGFpMul)
+EXTERN (ippsGFpExp)
+EXTERN (ippsGFpMultiExp)
+EXTERN (ippsGFpAdd_PE)
+EXTERN (ippsGFpSub_PE)
+EXTERN (ippsGFpMul_PE)
+EXTERN (ippsGFpECGetSize)
+EXTERN (ippsGFpECInit)
+EXTERN (ippsGFpECSet)
+EXTERN (ippsGFpECSetSubgroup)
+EXTERN (ippsGFpECInitStd128r1)
+EXTERN (ippsGFpECInitStd128r2)
+EXTERN (ippsGFpECInitStd192r1)
+EXTERN (ippsGFpECInitStd224r1)
+EXTERN (ippsGFpECInitStd256r1)
+EXTERN (ippsGFpECInitStd384r1)
+EXTERN (ippsGFpECInitStd521r1)
+EXTERN (ippsGFpECInitStdSM2)
+EXTERN (ippsGFpECInitStdBN256)
+EXTERN (ippsGFpECBindGxyTblStd192r1)
+EXTERN (ippsGFpECBindGxyTblStd224r1)
+EXTERN (ippsGFpECBindGxyTblStd256r1)
+EXTERN (ippsGFpECBindGxyTblStd384r1)
+EXTERN (ippsGFpECBindGxyTblStd521r1)
+EXTERN (ippsGFpECBindGxyTblStdSM2)
+EXTERN (ippsGFpECGet)
+EXTERN (ippsGFpECGetSubgroup)
+EXTERN (ippsGFpECScratchBufferSize)
+EXTERN (ippsGFpECVerify)
+EXTERN (ippsGFpECPointGetSize)
+EXTERN (ippsGFpECPointInit)
+EXTERN (ippsGFpECSetPointAtInfinity)
+EXTERN (ippsGFpECSetPoint)
+EXTERN (ippsGFpECSetPointRegular)
+EXTERN (ippsGFpECSetPointRandom)
+EXTERN (ippsGFpECMakePoint)
+EXTERN (ippsGFpECSetPointHash)
+EXTERN (ippsGFpECSetPointHash_rmf)
+EXTERN (ippsGFpECGetPoint)
+EXTERN (ippsGFpECGetPointRegular)
+EXTERN (ippsGFpECTstPoint)
+EXTERN (ippsGFpECTstPointInSubgroup)
+EXTERN (ippsGFpECCpyPoint)
+EXTERN (ippsGFpECCmpPoint)
+EXTERN (ippsGFpECNegPoint)
+EXTERN (ippsGFpECAddPoint)
+EXTERN (ippsGFpECMulPoint)
+EXTERN (ippsGFpECPrivateKey)
+EXTERN (ippsGFpECPublicKey)
+EXTERN (ippsGFpECTstKeyPair)
+EXTERN (ippsGFpECSharedSecretDH)
+EXTERN (ippsGFpECSharedSecretDHC)
+EXTERN (ippsGFpECSignDSA)
+EXTERN (ippsGFpECVerifyDSA)
+EXTERN (ippsGFpECSignNR)
+EXTERN (ippsGFpECVerifyNR)
+EXTERN (ippsGFpECSignSM2)
+EXTERN (ippsGFpECVerifySM2)
+EXTERN (ippsGFpECESGetSize_SM2)
+EXTERN (ippsGFpECESInit_SM2)
+EXTERN (ippsGFpECESSetKey_SM2)
+EXTERN (ippsGFpECESStart_SM2)
+EXTERN (ippsGFpECESEncrypt_SM2)
+EXTERN (ippsGFpECESDecrypt_SM2)
+EXTERN (ippsGFpECESFinal_SM2)
+EXTERN (ippsGFpECESGetBuffersSize_SM2)
+EXTERN (ippsGFpECSetPointOctString)
+EXTERN (ippsGFpECGetPointOctString)
+
+VERSION {
+ {
+ global:
+ ippcpGetLibVersion;
+ ippcpInit;
+ cpGetReg;
+ cpStartTscp;
+ cpStopTscp;
+ cpStartTsc;
+ cpStopTsc;
+ cpGetCacheSize;
+ ippcpSetCpuFeatures;
+ ippcpGetCpuFeatures;
+ ippcpGetCpuClocks;
+ ippcpSetNumThreads;
+ ippcpGetNumThreads;
+ ippcpGetEnabledCpuFeatures;
+ ippcpGetEnabledNumThreads;
+ ippcpGetStatusString;
+ ippsDESGetSize;
+ ippsDESInit;
+ ippsDESPack;
+ ippsDESUnpack;
+ ippsTDESEncryptECB;
+ ippsTDESDecryptECB;
+ ippsTDESEncryptCBC;
+ ippsTDESDecryptCBC;
+ ippsTDESEncryptCFB;
+ ippsTDESDecryptCFB;
+ ippsTDESEncryptOFB;
+ ippsTDESDecryptOFB;
+ ippsTDESEncryptCTR;
+ ippsTDESDecryptCTR;
+ ippsAESGetSize;
+ ippsAESInit;
+ ippsAESSetKey;
+ ippsAESPack;
+ ippsAESUnpack;
+ ippsAESEncryptECB;
+ ippsAESDecryptECB;
+ ippsAESEncryptCBC;
+ ippsAESEncryptCBC_CS1;
+ ippsAESEncryptCBC_CS2;
+ ippsAESEncryptCBC_CS3;
+ ippsAESDecryptCBC;
+ ippsAESDecryptCBC_CS1;
+ ippsAESDecryptCBC_CS2;
+ ippsAESDecryptCBC_CS3;
+ ippsAESEncryptCFB;
+ ippsAESDecryptCFB;
+ ippsAESEncryptOFB;
+ ippsAESDecryptOFB;
+ ippsAESEncryptCTR;
+ ippsAESDecryptCTR;
+ ippsAESEncryptXTS_Direct;
+ ippsAESDecryptXTS_Direct;
+ ippsSMS4GetSize;
+ ippsSMS4Init;
+ ippsSMS4SetKey;
+ ippsSMS4EncryptECB;
+ ippsSMS4DecryptECB;
+ ippsSMS4EncryptCBC;
+ ippsSMS4EncryptCBC_CS1;
+ ippsSMS4EncryptCBC_CS2;
+ ippsSMS4EncryptCBC_CS3;
+ ippsSMS4DecryptCBC;
+ ippsSMS4DecryptCBC_CS1;
+ ippsSMS4DecryptCBC_CS2;
+ ippsSMS4DecryptCBC_CS3;
+ ippsSMS4EncryptCFB;
+ ippsSMS4DecryptCFB;
+ ippsSMS4EncryptOFB;
+ ippsSMS4DecryptOFB;
+ ippsSMS4EncryptCTR;
+ ippsSMS4DecryptCTR;
+ ippsSMS4_CCMGetSize;
+ ippsSMS4_CCMInit;
+ ippsSMS4_CCMMessageLen;
+ ippsSMS4_CCMTagLen;
+ ippsSMS4_CCMStart;
+ ippsSMS4_CCMEncrypt;
+ ippsSMS4_CCMDecrypt;
+ ippsSMS4_CCMGetTag;
+ ippsAES_CCMGetSize;
+ ippsAES_CCMInit;
+ ippsAES_CCMMessageLen;
+ ippsAES_CCMTagLen;
+ ippsAES_CCMStart;
+ ippsAES_CCMEncrypt;
+ ippsAES_CCMDecrypt;
+ ippsAES_CCMGetTag;
+ ippsAES_GCMGetSize;
+ ippsAES_GCMInit;
+ ippsAES_GCMReset;
+ ippsAES_GCMProcessIV;
+ ippsAES_GCMProcessAAD;
+ ippsAES_GCMStart;
+ ippsAES_GCMEncrypt;
+ ippsAES_GCMDecrypt;
+ ippsAES_GCMGetTag;
+ ippsAES_XTSGetSize;
+ ippsAES_XTSInit;
+ ippsAES_XTSEncrypt;
+ ippsAES_XTSDecrypt;
+ ippsAES_S2V_CMAC;
+ ippsAES_SIVEncrypt;
+ ippsAES_SIVDecrypt;
+ ippsAES_CMACGetSize;
+ ippsAES_CMACInit;
+ ippsAES_CMACUpdate;
+ ippsAES_CMACFinal;
+ ippsAES_CMACGetTag;
+ ippsARCFourCheckKey;
+ ippsARCFourGetSize;
+ ippsARCFourInit;
+ ippsARCFourReset;
+ ippsARCFourPack;
+ ippsARCFourUnpack;
+ ippsARCFourEncrypt;
+ ippsARCFourDecrypt;
+ ippsSHA1GetSize;
+ ippsSHA1Init;
+ ippsSHA1Duplicate;
+ ippsSHA1Pack;
+ ippsSHA1Unpack;
+ ippsSHA1Update;
+ ippsSHA1GetTag;
+ ippsSHA1Final;
+ ippsSHA1MessageDigest;
+ ippsSHA224GetSize;
+ ippsSHA224Init;
+ ippsSHA224Duplicate;
+ ippsSHA224Pack;
+ ippsSHA224Unpack;
+ ippsSHA224Update;
+ ippsSHA224GetTag;
+ ippsSHA224Final;
+ ippsSHA224MessageDigest;
+ ippsSHA256GetSize;
+ ippsSHA256Init;
+ ippsSHA256Duplicate;
+ ippsSHA256Pack;
+ ippsSHA256Unpack;
+ ippsSHA256Update;
+ ippsSHA256GetTag;
+ ippsSHA256Final;
+ ippsSHA256MessageDigest;
+ ippsSHA384GetSize;
+ ippsSHA384Init;
+ ippsSHA384Duplicate;
+ ippsSHA384Pack;
+ ippsSHA384Unpack;
+ ippsSHA384Update;
+ ippsSHA384GetTag;
+ ippsSHA384Final;
+ ippsSHA384MessageDigest;
+ ippsSHA512GetSize;
+ ippsSHA512Init;
+ ippsSHA512Duplicate;
+ ippsSHA512Pack;
+ ippsSHA512Unpack;
+ ippsSHA512Update;
+ ippsSHA512GetTag;
+ ippsSHA512Final;
+ ippsSHA512MessageDigest;
+ ippsMD5GetSize;
+ ippsMD5Init;
+ ippsMD5Duplicate;
+ ippsMD5Pack;
+ ippsMD5Unpack;
+ ippsMD5Update;
+ ippsMD5GetTag;
+ ippsMD5Final;
+ ippsMD5MessageDigest;
+ ippsSM3GetSize;
+ ippsSM3Init;
+ ippsSM3Duplicate;
+ ippsSM3Pack;
+ ippsSM3Unpack;
+ ippsSM3Update;
+ ippsSM3GetTag;
+ ippsSM3Final;
+ ippsSM3MessageDigest;
+ ippsHashGetSize;
+ ippsHashInit;
+ ippsHashPack;
+ ippsHashUnpack;
+ ippsHashDuplicate;
+ ippsHashUpdate;
+ ippsHashGetTag;
+ ippsHashFinal;
+ ippsHashMessage;
+ ippsHashMethod_MD5;
+ ippsHashMethod_SM3;
+ ippsHashMethod_SHA1;
+ ippsHashMethod_SHA1_NI;
+ ippsHashMethod_SHA1_TT;
+ ippsHashMethod_SHA256;
+ ippsHashMethod_SHA256_NI;
+ ippsHashMethod_SHA256_TT;
+ ippsHashMethod_SHA224;
+ ippsHashMethod_SHA224_NI;
+ ippsHashMethod_SHA224_TT;
+ ippsHashMethod_SHA512;
+ ippsHashMethod_SHA384;
+ ippsHashMethod_SHA512_256;
+ ippsHashMethod_SHA512_224;
+ ippsHashGetSize_rmf;
+ ippsHashInit_rmf;
+ ippsHashPack_rmf;
+ ippsHashUnpack_rmf;
+ ippsHashDuplicate_rmf;
+ ippsHashUpdate_rmf;
+ ippsHashGetTag_rmf;
+ ippsHashFinal_rmf;
+ ippsHashMessage_rmf;
+ ippsMGF;
+ ippsMGF1_rmf;
+ ippsMGF2_rmf;
+ ippsHMAC_GetSize;
+ ippsHMAC_Init;
+ ippsHMAC_Pack;
+ ippsHMAC_Unpack;
+ ippsHMAC_Duplicate;
+ ippsHMAC_Update;
+ ippsHMAC_Final;
+ ippsHMAC_GetTag;
+ ippsHMAC_Message;
+ ippsHMACGetSize_rmf;
+ ippsHMACInit_rmf;
+ ippsHMACPack_rmf;
+ ippsHMACUnpack_rmf;
+ ippsHMACDuplicate_rmf;
+ ippsHMACUpdate_rmf;
+ ippsHMACFinal_rmf;
+ ippsHMACGetTag_rmf;
+ ippsHMACMessage_rmf;
+ ippsBigNumGetSize;
+ ippsBigNumInit;
+ ippsCmpZero_BN;
+ ippsCmp_BN;
+ ippsGetSize_BN;
+ ippsSet_BN;
+ ippsGet_BN;
+ ippsRef_BN;
+ ippsExtGet_BN;
+ ippsAdd_BN;
+ ippsSub_BN;
+ ippsMul_BN;
+ ippsMAC_BN_I;
+ ippsDiv_BN;
+ ippsMod_BN;
+ ippsGcd_BN;
+ ippsModInv_BN;
+ ippsSetOctString_BN;
+ ippsGetOctString_BN;
+ ippsMontGetSize;
+ ippsMontInit;
+ ippsMontSet;
+ ippsMontGet;
+ ippsMontForm;
+ ippsMontMul;
+ ippsMontExp;
+ ippsPRNGGetSize;
+ ippsPRNGInit;
+ ippsPRNGSetModulus;
+ ippsPRNGSetH0;
+ ippsPRNGSetAugment;
+ ippsPRNGSetSeed;
+ ippsPRNGGetSeed;
+ ippsPRNGen;
+ ippsPRNGen_BN;
+ ippsPRNGenRDRAND;
+ ippsPRNGenRDRAND_BN;
+ ippsTRNGenRDSEED;
+ ippsTRNGenRDSEED_BN;
+ ippsPrimeGetSize;
+ ippsPrimeInit;
+ ippsPrimeGen;
+ ippsPrimeTest;
+ ippsPrimeGen_BN;
+ ippsPrimeTest_BN;
+ ippsPrimeGet;
+ ippsPrimeGet_BN;
+ ippsPrimeSet;
+ ippsPrimeSet_BN;
+ ippsRSA_GetSizePublicKey;
+ ippsRSA_InitPublicKey;
+ ippsRSA_SetPublicKey;
+ ippsRSA_GetPublicKey;
+ ippsRSA_GetSizePrivateKeyType1;
+ ippsRSA_InitPrivateKeyType1;
+ ippsRSA_SetPrivateKeyType1;
+ ippsRSA_GetPrivateKeyType1;
+ ippsRSA_GetSizePrivateKeyType2;
+ ippsRSA_InitPrivateKeyType2;
+ ippsRSA_SetPrivateKeyType2;
+ ippsRSA_GetPrivateKeyType2;
+ ippsRSA_GetBufferSizePublicKey;
+ ippsRSA_GetBufferSizePrivateKey;
+ ippsRSA_Encrypt;
+ ippsRSA_Decrypt;
+ ippsRSA_GenerateKeys;
+ ippsRSA_ValidateKeys;
+ ippsRSAEncrypt_OAEP;
+ ippsRSADecrypt_OAEP;
+ ippsRSAEncrypt_OAEP_rmf;
+ ippsRSADecrypt_OAEP_rmf;
+ ippsRSAEncrypt_PKCSv15;
+ ippsRSADecrypt_PKCSv15;
+ ippsRSASign_PSS;
+ ippsRSAVerify_PSS;
+ ippsRSASign_PSS_rmf;
+ ippsRSAVerify_PSS_rmf;
+ ippsRSASign_PKCS1v15;
+ ippsRSAVerify_PKCS1v15;
+ ippsRSASign_PKCS1v15_rmf;
+ ippsRSAVerify_PKCS1v15_rmf;
+ ippsDLGetResultString;
+ ippsDLPGetSize;
+ ippsDLPInit;
+ ippsDLPPack;
+ ippsDLPUnpack;
+ ippsDLPSet;
+ ippsDLPGet;
+ ippsDLPSetDP;
+ ippsDLPGetDP;
+ ippsDLPGenKeyPair;
+ ippsDLPPublicKey;
+ ippsDLPValidateKeyPair;
+ ippsDLPSetKeyPair;
+ ippsDLPSignDSA;
+ ippsDLPVerifyDSA;
+ ippsDLPSharedSecretDH;
+ ippsDLPGenerateDSA;
+ ippsDLPValidateDSA;
+ ippsDLPGenerateDH;
+ ippsDLPValidateDH;
+ ippsECCGetResultString;
+ ippsECCPGetSize;
+ ippsECCPGetSizeStd128r1;
+ ippsECCPGetSizeStd128r2;
+ ippsECCPGetSizeStd192r1;
+ ippsECCPGetSizeStd224r1;
+ ippsECCPGetSizeStd256r1;
+ ippsECCPGetSizeStd384r1;
+ ippsECCPGetSizeStd521r1;
+ ippsECCPGetSizeStdSM2;
+ ippsECCPInit;
+ ippsECCPInitStd128r1;
+ ippsECCPInitStd128r2;
+ ippsECCPInitStd192r1;
+ ippsECCPInitStd224r1;
+ ippsECCPInitStd256r1;
+ ippsECCPInitStd384r1;
+ ippsECCPInitStd521r1;
+ ippsECCPInitStdSM2;
+ ippsECCPSet;
+ ippsECCPSetStd;
+ ippsECCPSetStd128r1;
+ ippsECCPSetStd128r2;
+ ippsECCPSetStd192r1;
+ ippsECCPSetStd224r1;
+ ippsECCPSetStd256r1;
+ ippsECCPSetStd384r1;
+ ippsECCPSetStd521r1;
+ ippsECCPSetStdSM2;
+ ippsECCPBindGxyTblStd192r1;
+ ippsECCPBindGxyTblStd224r1;
+ ippsECCPBindGxyTblStd256r1;
+ ippsECCPBindGxyTblStd384r1;
+ ippsECCPBindGxyTblStd521r1;
+ ippsECCPBindGxyTblStdSM2;
+ ippsECCPGet;
+ ippsECCPGetOrderBitSize;
+ ippsECCPValidate;
+ ippsECCPPointGetSize;
+ ippsECCPPointInit;
+ ippsECCPSetPoint;
+ ippsECCPSetPointAtInfinity;
+ ippsECCPGetPoint;
+ ippsECCPCheckPoint;
+ ippsECCPComparePoint;
+ ippsECCPNegativePoint;
+ ippsECCPAddPoint;
+ ippsECCPMulPointScalar;
+ ippsECCPGenKeyPair;
+ ippsECCPPublicKey;
+ ippsECCPValidateKeyPair;
+ ippsECCPSetKeyPair;
+ ippsECCPSharedSecretDH;
+ ippsECCPSharedSecretDHC;
+ ippsECCPSignDSA;
+ ippsECCPVerifyDSA;
+ ippsECCPSignNR;
+ ippsECCPVerifyNR;
+ ippsECCPSignSM2;
+ ippsECCPVerifySM2;
+ ippsGFpGetSize;
+ ippsGFpInitArbitrary;
+ ippsGFpInitFixed;
+ ippsGFpInit;
+ ippsGFpMethod_p192r1;
+ ippsGFpMethod_p224r1;
+ ippsGFpMethod_p256r1;
+ ippsGFpMethod_p384r1;
+ ippsGFpMethod_p521r1;
+ ippsGFpMethod_p256sm2;
+ ippsGFpMethod_p256bn;
+ ippsGFpMethod_p256;
+ ippsGFpMethod_pArb;
+ ippsGFpxGetSize;
+ ippsGFpxInit;
+ ippsGFpxInitBinomial;
+ ippsGFpxMethod_binom2_epid2;
+ ippsGFpxMethod_binom3_epid2;
+ ippsGFpxMethod_binom2;
+ ippsGFpxMethod_binom3;
+ ippsGFpxMethod_binom;
+ ippsGFpxMethod_com;
+ ippsGFpScratchBufferSize;
+ ippsGFpElementGetSize;
+ ippsGFpElementInit;
+ ippsGFpSetElement;
+ ippsGFpSetElementRegular;
+ ippsGFpSetElementOctString;
+ ippsGFpSetElementRandom;
+ ippsGFpSetElementHash;
+ ippsGFpSetElementHash_rmf;
+ ippsGFpCpyElement;
+ ippsGFpGetElement;
+ ippsGFpGetElementOctString;
+ ippsGFpCmpElement;
+ ippsGFpIsZeroElement;
+ ippsGFpIsUnityElement;
+ ippsGFpConj;
+ ippsGFpNeg;
+ ippsGFpInv;
+ ippsGFpSqrt;
+ ippsGFpSqr;
+ ippsGFpAdd;
+ ippsGFpSub;
+ ippsGFpMul;
+ ippsGFpExp;
+ ippsGFpMultiExp;
+ ippsGFpAdd_PE;
+ ippsGFpSub_PE;
+ ippsGFpMul_PE;
+ ippsGFpECGetSize;
+ ippsGFpECInit;
+ ippsGFpECSet;
+ ippsGFpECSetSubgroup;
+ ippsGFpECInitStd128r1;
+ ippsGFpECInitStd128r2;
+ ippsGFpECInitStd192r1;
+ ippsGFpECInitStd224r1;
+ ippsGFpECInitStd256r1;
+ ippsGFpECInitStd384r1;
+ ippsGFpECInitStd521r1;
+ ippsGFpECInitStdSM2;
+ ippsGFpECInitStdBN256;
+ ippsGFpECBindGxyTblStd192r1;
+ ippsGFpECBindGxyTblStd224r1;
+ ippsGFpECBindGxyTblStd256r1;
+ ippsGFpECBindGxyTblStd384r1;
+ ippsGFpECBindGxyTblStd521r1;
+ ippsGFpECBindGxyTblStdSM2;
+ ippsGFpECGet;
+ ippsGFpECGetSubgroup;
+ ippsGFpECScratchBufferSize;
+ ippsGFpECVerify;
+ ippsGFpECPointGetSize;
+ ippsGFpECPointInit;
+ ippsGFpECSetPointAtInfinity;
+ ippsGFpECSetPoint;
+ ippsGFpECSetPointRegular;
+ ippsGFpECSetPointRandom;
+ ippsGFpECMakePoint;
+ ippsGFpECSetPointHash;
+ ippsGFpECSetPointHash_rmf;
+ ippsGFpECGetPoint;
+ ippsGFpECGetPointRegular;
+ ippsGFpECTstPoint;
+ ippsGFpECTstPointInSubgroup;
+ ippsGFpECCpyPoint;
+ ippsGFpECCmpPoint;
+ ippsGFpECNegPoint;
+ ippsGFpECAddPoint;
+ ippsGFpECMulPoint;
+ ippsGFpECPrivateKey;
+ ippsGFpECPublicKey;
+ ippsGFpECTstKeyPair;
+ ippsGFpECSharedSecretDH;
+ ippsGFpECSharedSecretDHC;
+ ippsGFpECSignDSA;
+ ippsGFpECVerifyDSA;
+ ippsGFpECSignNR;
+ ippsGFpECVerifyNR;
+ ippsGFpECSignSM2;
+ ippsGFpECVerifySM2;
+ ippsGFpECESGetSize_SM2;
+ ippsGFpECESInit_SM2;
+ ippsGFpECESSetKey_SM2;
+ ippsGFpECESStart_SM2;
+ ippsGFpECESEncrypt_SM2;
+ ippsGFpECESDecrypt_SM2;
+ ippsGFpECESFinal_SM2;
+ ippsGFpECESGetBuffersSize_SM2;
+ ippsGFpECSetPointOctString;
+ ippsGFpECGetPointOctString;
+ local: *;
+ };
+}
diff --git a/ext/ipp/sources/ippcp/exports.macosx.lib-export b/ext/ipp/sources/ippcp/exports.macosx.lib-export
new file mode 100644
index 0000000..92d3408
--- /dev/null
+++ b/ext/ipp/sources/ippcp/exports.macosx.lib-export
@@ -0,0 +1,507 @@
+_ippcpGetLibVersion
+_ippcpInit
+_cpGetReg
+_cpStartTscp
+_cpStopTscp
+_cpStartTsc
+_cpStopTsc
+_cpGetCacheSize
+_ippcpSetCpuFeatures
+_ippcpGetCpuFeatures
+_ippcpGetCpuClocks
+_ippcpSetNumThreads
+_ippcpGetNumThreads
+_ippcpGetEnabledCpuFeatures
+_ippcpGetEnabledNumThreads
+_ippcpGetStatusString
+_ippsDESGetSize
+_ippsDESInit
+_ippsDESPack
+_ippsDESUnpack
+_ippsTDESEncryptECB
+_ippsTDESDecryptECB
+_ippsTDESEncryptCBC
+_ippsTDESDecryptCBC
+_ippsTDESEncryptCFB
+_ippsTDESDecryptCFB
+_ippsTDESEncryptOFB
+_ippsTDESDecryptOFB
+_ippsTDESEncryptCTR
+_ippsTDESDecryptCTR
+_ippsAESGetSize
+_ippsAESInit
+_ippsAESSetKey
+_ippsAESPack
+_ippsAESUnpack
+_ippsAESEncryptECB
+_ippsAESDecryptECB
+_ippsAESEncryptCBC
+_ippsAESEncryptCBC_CS1
+_ippsAESEncryptCBC_CS2
+_ippsAESEncryptCBC_CS3
+_ippsAESDecryptCBC
+_ippsAESDecryptCBC_CS1
+_ippsAESDecryptCBC_CS2
+_ippsAESDecryptCBC_CS3
+_ippsAESEncryptCFB
+_ippsAESDecryptCFB
+_ippsAESEncryptOFB
+_ippsAESDecryptOFB
+_ippsAESEncryptCTR
+_ippsAESDecryptCTR
+_ippsAESEncryptXTS_Direct
+_ippsAESDecryptXTS_Direct
+_ippsSMS4GetSize
+_ippsSMS4Init
+_ippsSMS4SetKey
+_ippsSMS4EncryptECB
+_ippsSMS4DecryptECB
+_ippsSMS4EncryptCBC
+_ippsSMS4EncryptCBC_CS1
+_ippsSMS4EncryptCBC_CS2
+_ippsSMS4EncryptCBC_CS3
+_ippsSMS4DecryptCBC
+_ippsSMS4DecryptCBC_CS1
+_ippsSMS4DecryptCBC_CS2
+_ippsSMS4DecryptCBC_CS3
+_ippsSMS4EncryptCFB
+_ippsSMS4DecryptCFB
+_ippsSMS4EncryptOFB
+_ippsSMS4DecryptOFB
+_ippsSMS4EncryptCTR
+_ippsSMS4DecryptCTR
+_ippsSMS4_CCMGetSize
+_ippsSMS4_CCMInit
+_ippsSMS4_CCMMessageLen
+_ippsSMS4_CCMTagLen
+_ippsSMS4_CCMStart
+_ippsSMS4_CCMEncrypt
+_ippsSMS4_CCMDecrypt
+_ippsSMS4_CCMGetTag
+_ippsAES_CCMGetSize
+_ippsAES_CCMInit
+_ippsAES_CCMMessageLen
+_ippsAES_CCMTagLen
+_ippsAES_CCMStart
+_ippsAES_CCMEncrypt
+_ippsAES_CCMDecrypt
+_ippsAES_CCMGetTag
+_ippsAES_GCMGetSize
+_ippsAES_GCMInit
+_ippsAES_GCMReset
+_ippsAES_GCMProcessIV
+_ippsAES_GCMProcessAAD
+_ippsAES_GCMStart
+_ippsAES_GCMEncrypt
+_ippsAES_GCMDecrypt
+_ippsAES_GCMGetTag
+_ippsAES_XTSGetSize
+_ippsAES_XTSInit
+_ippsAES_XTSEncrypt
+_ippsAES_XTSDecrypt
+_ippsAES_S2V_CMAC
+_ippsAES_SIVEncrypt
+_ippsAES_SIVDecrypt
+_ippsAES_CMACGetSize
+_ippsAES_CMACInit
+_ippsAES_CMACUpdate
+_ippsAES_CMACFinal
+_ippsAES_CMACGetTag
+_ippsARCFourCheckKey
+_ippsARCFourGetSize
+_ippsARCFourInit
+_ippsARCFourReset
+_ippsARCFourPack
+_ippsARCFourUnpack
+_ippsARCFourEncrypt
+_ippsARCFourDecrypt
+_ippsSHA1GetSize
+_ippsSHA1Init
+_ippsSHA1Duplicate
+_ippsSHA1Pack
+_ippsSHA1Unpack
+_ippsSHA1Update
+_ippsSHA1GetTag
+_ippsSHA1Final
+_ippsSHA1MessageDigest
+_ippsSHA224GetSize
+_ippsSHA224Init
+_ippsSHA224Duplicate
+_ippsSHA224Pack
+_ippsSHA224Unpack
+_ippsSHA224Update
+_ippsSHA224GetTag
+_ippsSHA224Final
+_ippsSHA224MessageDigest
+_ippsSHA256GetSize
+_ippsSHA256Init
+_ippsSHA256Duplicate
+_ippsSHA256Pack
+_ippsSHA256Unpack
+_ippsSHA256Update
+_ippsSHA256GetTag
+_ippsSHA256Final
+_ippsSHA256MessageDigest
+_ippsSHA384GetSize
+_ippsSHA384Init
+_ippsSHA384Duplicate
+_ippsSHA384Pack
+_ippsSHA384Unpack
+_ippsSHA384Update
+_ippsSHA384GetTag
+_ippsSHA384Final
+_ippsSHA384MessageDigest
+_ippsSHA512GetSize
+_ippsSHA512Init
+_ippsSHA512Duplicate
+_ippsSHA512Pack
+_ippsSHA512Unpack
+_ippsSHA512Update
+_ippsSHA512GetTag
+_ippsSHA512Final
+_ippsSHA512MessageDigest
+_ippsMD5GetSize
+_ippsMD5Init
+_ippsMD5Duplicate
+_ippsMD5Pack
+_ippsMD5Unpack
+_ippsMD5Update
+_ippsMD5GetTag
+_ippsMD5Final
+_ippsMD5MessageDigest
+_ippsSM3GetSize
+_ippsSM3Init
+_ippsSM3Duplicate
+_ippsSM3Pack
+_ippsSM3Unpack
+_ippsSM3Update
+_ippsSM3GetTag
+_ippsSM3Final
+_ippsSM3MessageDigest
+_ippsHashGetSize
+_ippsHashInit
+_ippsHashPack
+_ippsHashUnpack
+_ippsHashDuplicate
+_ippsHashUpdate
+_ippsHashGetTag
+_ippsHashFinal
+_ippsHashMessage
+_ippsHashMethod_MD5
+_ippsHashMethod_SM3
+_ippsHashMethod_SHA1
+_ippsHashMethod_SHA1_NI
+_ippsHashMethod_SHA1_TT
+_ippsHashMethod_SHA256
+_ippsHashMethod_SHA256_NI
+_ippsHashMethod_SHA256_TT
+_ippsHashMethod_SHA224
+_ippsHashMethod_SHA224_NI
+_ippsHashMethod_SHA224_TT
+_ippsHashMethod_SHA512
+_ippsHashMethod_SHA384
+_ippsHashMethod_SHA512_256
+_ippsHashMethod_SHA512_224
+_ippsHashGetSize_rmf
+_ippsHashInit_rmf
+_ippsHashPack_rmf
+_ippsHashUnpack_rmf
+_ippsHashDuplicate_rmf
+_ippsHashUpdate_rmf
+_ippsHashGetTag_rmf
+_ippsHashFinal_rmf
+_ippsHashMessage_rmf
+_ippsMGF
+_ippsMGF1_rmf
+_ippsMGF2_rmf
+_ippsHMAC_GetSize
+_ippsHMAC_Init
+_ippsHMAC_Pack
+_ippsHMAC_Unpack
+_ippsHMAC_Duplicate
+_ippsHMAC_Update
+_ippsHMAC_Final
+_ippsHMAC_GetTag
+_ippsHMAC_Message
+_ippsHMACGetSize_rmf
+_ippsHMACInit_rmf
+_ippsHMACPack_rmf
+_ippsHMACUnpack_rmf
+_ippsHMACDuplicate_rmf
+_ippsHMACUpdate_rmf
+_ippsHMACFinal_rmf
+_ippsHMACGetTag_rmf
+_ippsHMACMessage_rmf
+_ippsBigNumGetSize
+_ippsBigNumInit
+_ippsCmpZero_BN
+_ippsCmp_BN
+_ippsGetSize_BN
+_ippsSet_BN
+_ippsGet_BN
+_ippsRef_BN
+_ippsExtGet_BN
+_ippsAdd_BN
+_ippsSub_BN
+_ippsMul_BN
+_ippsMAC_BN_I
+_ippsDiv_BN
+_ippsMod_BN
+_ippsGcd_BN
+_ippsModInv_BN
+_ippsSetOctString_BN
+_ippsGetOctString_BN
+_ippsMontGetSize
+_ippsMontInit
+_ippsMontSet
+_ippsMontGet
+_ippsMontForm
+_ippsMontMul
+_ippsMontExp
+_ippsPRNGGetSize
+_ippsPRNGInit
+_ippsPRNGSetModulus
+_ippsPRNGSetH0
+_ippsPRNGSetAugment
+_ippsPRNGSetSeed
+_ippsPRNGGetSeed
+_ippsPRNGen
+_ippsPRNGen_BN
+_ippsPRNGenRDRAND
+_ippsPRNGenRDRAND_BN
+_ippsTRNGenRDSEED
+_ippsTRNGenRDSEED_BN
+_ippsPrimeGetSize
+_ippsPrimeInit
+_ippsPrimeGen
+_ippsPrimeTest
+_ippsPrimeGen_BN
+_ippsPrimeTest_BN
+_ippsPrimeGet
+_ippsPrimeGet_BN
+_ippsPrimeSet
+_ippsPrimeSet_BN
+_ippsRSA_GetSizePublicKey
+_ippsRSA_InitPublicKey
+_ippsRSA_SetPublicKey
+_ippsRSA_GetPublicKey
+_ippsRSA_GetSizePrivateKeyType1
+_ippsRSA_InitPrivateKeyType1
+_ippsRSA_SetPrivateKeyType1
+_ippsRSA_GetPrivateKeyType1
+_ippsRSA_GetSizePrivateKeyType2
+_ippsRSA_InitPrivateKeyType2
+_ippsRSA_SetPrivateKeyType2
+_ippsRSA_GetPrivateKeyType2
+_ippsRSA_GetBufferSizePublicKey
+_ippsRSA_GetBufferSizePrivateKey
+_ippsRSA_Encrypt
+_ippsRSA_Decrypt
+_ippsRSA_GenerateKeys
+_ippsRSA_ValidateKeys
+_ippsRSAEncrypt_OAEP
+_ippsRSADecrypt_OAEP
+_ippsRSAEncrypt_OAEP_rmf
+_ippsRSADecrypt_OAEP_rmf
+_ippsRSAEncrypt_PKCSv15
+_ippsRSADecrypt_PKCSv15
+_ippsRSASign_PSS
+_ippsRSAVerify_PSS
+_ippsRSASign_PSS_rmf
+_ippsRSAVerify_PSS_rmf
+_ippsRSASign_PKCS1v15
+_ippsRSAVerify_PKCS1v15
+_ippsRSASign_PKCS1v15_rmf
+_ippsRSAVerify_PKCS1v15_rmf
+_ippsDLGetResultString
+_ippsDLPGetSize
+_ippsDLPInit
+_ippsDLPPack
+_ippsDLPUnpack
+_ippsDLPSet
+_ippsDLPGet
+_ippsDLPSetDP
+_ippsDLPGetDP
+_ippsDLPGenKeyPair
+_ippsDLPPublicKey
+_ippsDLPValidateKeyPair
+_ippsDLPSetKeyPair
+_ippsDLPSignDSA
+_ippsDLPVerifyDSA
+_ippsDLPSharedSecretDH
+_ippsDLPGenerateDSA
+_ippsDLPValidateDSA
+_ippsDLPGenerateDH
+_ippsDLPValidateDH
+_ippsECCGetResultString
+_ippsECCPGetSize
+_ippsECCPGetSizeStd128r1
+_ippsECCPGetSizeStd128r2
+_ippsECCPGetSizeStd192r1
+_ippsECCPGetSizeStd224r1
+_ippsECCPGetSizeStd256r1
+_ippsECCPGetSizeStd384r1
+_ippsECCPGetSizeStd521r1
+_ippsECCPGetSizeStdSM2
+_ippsECCPInit
+_ippsECCPInitStd128r1
+_ippsECCPInitStd128r2
+_ippsECCPInitStd192r1
+_ippsECCPInitStd224r1
+_ippsECCPInitStd256r1
+_ippsECCPInitStd384r1
+_ippsECCPInitStd521r1
+_ippsECCPInitStdSM2
+_ippsECCPSet
+_ippsECCPSetStd
+_ippsECCPSetStd128r1
+_ippsECCPSetStd128r2
+_ippsECCPSetStd192r1
+_ippsECCPSetStd224r1
+_ippsECCPSetStd256r1
+_ippsECCPSetStd384r1
+_ippsECCPSetStd521r1
+_ippsECCPSetStdSM2
+_ippsECCPBindGxyTblStd192r1
+_ippsECCPBindGxyTblStd224r1
+_ippsECCPBindGxyTblStd256r1
+_ippsECCPBindGxyTblStd384r1
+_ippsECCPBindGxyTblStd521r1
+_ippsECCPBindGxyTblStdSM2
+_ippsECCPGet
+_ippsECCPGetOrderBitSize
+_ippsECCPValidate
+_ippsECCPPointGetSize
+_ippsECCPPointInit
+_ippsECCPSetPoint
+_ippsECCPSetPointAtInfinity
+_ippsECCPGetPoint
+_ippsECCPCheckPoint
+_ippsECCPComparePoint
+_ippsECCPNegativePoint
+_ippsECCPAddPoint
+_ippsECCPMulPointScalar
+_ippsECCPGenKeyPair
+_ippsECCPPublicKey
+_ippsECCPValidateKeyPair
+_ippsECCPSetKeyPair
+_ippsECCPSharedSecretDH
+_ippsECCPSharedSecretDHC
+_ippsECCPSignDSA
+_ippsECCPVerifyDSA
+_ippsECCPSignNR
+_ippsECCPVerifyNR
+_ippsECCPSignSM2
+_ippsECCPVerifySM2
+_ippsGFpGetSize
+_ippsGFpInitArbitrary
+_ippsGFpInitFixed
+_ippsGFpInit
+_ippsGFpMethod_p192r1
+_ippsGFpMethod_p224r1
+_ippsGFpMethod_p256r1
+_ippsGFpMethod_p384r1
+_ippsGFpMethod_p521r1
+_ippsGFpMethod_p256sm2
+_ippsGFpMethod_p256bn
+_ippsGFpMethod_p256
+_ippsGFpMethod_pArb
+_ippsGFpxGetSize
+_ippsGFpxInit
+_ippsGFpxInitBinomial
+_ippsGFpxMethod_binom2_epid2
+_ippsGFpxMethod_binom3_epid2
+_ippsGFpxMethod_binom2
+_ippsGFpxMethod_binom3
+_ippsGFpxMethod_binom
+_ippsGFpxMethod_com
+_ippsGFpScratchBufferSize
+_ippsGFpElementGetSize
+_ippsGFpElementInit
+_ippsGFpSetElement
+_ippsGFpSetElementRegular
+_ippsGFpSetElementOctString
+_ippsGFpSetElementRandom
+_ippsGFpSetElementHash
+_ippsGFpSetElementHash_rmf
+_ippsGFpCpyElement
+_ippsGFpGetElement
+_ippsGFpGetElementOctString
+_ippsGFpCmpElement
+_ippsGFpIsZeroElement
+_ippsGFpIsUnityElement
+_ippsGFpConj
+_ippsGFpNeg
+_ippsGFpInv
+_ippsGFpSqrt
+_ippsGFpSqr
+_ippsGFpAdd
+_ippsGFpSub
+_ippsGFpMul
+_ippsGFpExp
+_ippsGFpMultiExp
+_ippsGFpAdd_PE
+_ippsGFpSub_PE
+_ippsGFpMul_PE
+_ippsGFpECGetSize
+_ippsGFpECInit
+_ippsGFpECSet
+_ippsGFpECSetSubgroup
+_ippsGFpECInitStd128r1
+_ippsGFpECInitStd128r2
+_ippsGFpECInitStd192r1
+_ippsGFpECInitStd224r1
+_ippsGFpECInitStd256r1
+_ippsGFpECInitStd384r1
+_ippsGFpECInitStd521r1
+_ippsGFpECInitStdSM2
+_ippsGFpECInitStdBN256
+_ippsGFpECBindGxyTblStd192r1
+_ippsGFpECBindGxyTblStd224r1
+_ippsGFpECBindGxyTblStd256r1
+_ippsGFpECBindGxyTblStd384r1
+_ippsGFpECBindGxyTblStd521r1
+_ippsGFpECBindGxyTblStdSM2
+_ippsGFpECGet
+_ippsGFpECGetSubgroup
+_ippsGFpECScratchBufferSize
+_ippsGFpECVerify
+_ippsGFpECPointGetSize
+_ippsGFpECPointInit
+_ippsGFpECSetPointAtInfinity
+_ippsGFpECSetPoint
+_ippsGFpECSetPointRegular
+_ippsGFpECSetPointRandom
+_ippsGFpECMakePoint
+_ippsGFpECSetPointHash
+_ippsGFpECSetPointHash_rmf
+_ippsGFpECGetPoint
+_ippsGFpECGetPointRegular
+_ippsGFpECTstPoint
+_ippsGFpECTstPointInSubgroup
+_ippsGFpECCpyPoint
+_ippsGFpECCmpPoint
+_ippsGFpECNegPoint
+_ippsGFpECAddPoint
+_ippsGFpECMulPoint
+_ippsGFpECPrivateKey
+_ippsGFpECPublicKey
+_ippsGFpECTstKeyPair
+_ippsGFpECSharedSecretDH
+_ippsGFpECSharedSecretDHC
+_ippsGFpECSignDSA
+_ippsGFpECVerifyDSA
+_ippsGFpECSignNR
+_ippsGFpECVerifyNR
+_ippsGFpECSignSM2
+_ippsGFpECVerifySM2
+_ippsGFpECESGetSize_SM2
+_ippsGFpECESInit_SM2
+_ippsGFpECESSetKey_SM2
+_ippsGFpECESStart_SM2
+_ippsGFpECESEncrypt_SM2
+_ippsGFpECESDecrypt_SM2
+_ippsGFpECESFinal_SM2
+_ippsGFpECESGetBuffersSize_SM2
+_ippsGFpECSetPointOctString
+_ippsGFpECGetPointOctString
diff --git a/ext/ipp/sources/ippcp/src/gsmodinv.c b/ext/ipp/sources/ippcp/gsmod_almmontinv.c
index 30e181b..a907aae 100644
--- a/ext/ipp/sources/ippcp/src/gsmodinv.c
+++ b/ext/ipp/sources/ippcp/gsmod_almmontinv.c
@@ -1,32 +1,65 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// alm_mont_inv()
+//
+*/
+
#include "owndefs.h"
#include "owncp.h"
#include "pcpbnumisc.h"
#include "pcpbnuarith.h"
-
#include "gsmodstuff.h"
+#include "pcpmask_ct.h"
-//gres: temporary excluded: #include <assert.h>
-
-/* almost Montgomery Inverse
+/*
+// almost Montgomery Inverse
//
-// returns (k,r), r = (1/a)^k mod m
+// returns (k,r), r = (1/a)*(2^k) mod m
//
-// requires buffer with size 4 * modLen
*/
int alm_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME)
{
@@ -93,74 +126,3 @@ int alm_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME)
gsModPoolFree(pME, polLength);
return k;
}
-
-/*
-// returns r = mont(a^-1)
-// a in desidue domain
-// r in Montgomery domain
-*/
-BNU_CHUNK_T* gs_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME)
-{
- int k = alm_mont_inv(pr, pa, pME);
-
- if(0==k)
- pr = NULL;
-
- else {
- int mLen = MOD_LEN(pME);
- int m = mLen*BNU_CHUNK_BITS;
- mod_mul mon_mul = MOD_METHOD(pME)->mul;
-
- BNU_CHUNK_T* t = gsModPoolAlloc(pME, 1);
- //gres: temporary excluded: assert(NULL!=t);
-
- if(k<=m) {
- mon_mul(pr, pr, MOD_MNT_R2(pME), pME);
- k += m;
- }
-
- ZEXPAND_BNU(t, 0, mLen);
- SET_BIT(t, 2*m-k); /* t = 2^(2*m-k) */
- mon_mul(pr, pr, t, pME);
-
- gsModPoolFree(pME, 1);
- }
-
- return pr;
-}
-
-/*
-// returns r =1/a
-// a in desidue domain
-// r in desidue domain
-*/
-BNU_CHUNK_T* gs_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME)
-{
- int k = alm_mont_inv(pr, pa, pME);
-
- if(0==k)
- pr = NULL;
-
- else {
- int mLen = MOD_LEN(pME);
- int m = mLen*BNU_CHUNK_BITS;
- mod_mul mon_mul = MOD_METHOD(pME)->mul;
-
- BNU_CHUNK_T* t = gsModPoolAlloc(pME, 1);
- //gres: temporary excluded: assert(NULL!=t);
-
- if(k>m) {
- ZEXPAND_BNU(t, 0, mLen);
- t[0] = 1;
- mon_mul(pr, pr, t, pME);
- k -= m;
- }
- ZEXPAND_BNU(t, 0, mLen);
- SET_BIT(t, m-k); /* t = 2^(m-k) */
- mon_mul(pr, pr, t, pME);
-
- gsModPoolFree(pME, 1);
- }
-
- return pr;
-}
diff --git a/ext/ipp/sources/ippcp/gsmod_almmontinv_ct.c b/ext/ipp/sources/ippcp/gsmod_almmontinv_ct.c
new file mode 100644
index 0000000..23b096f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_almmontinv_ct.c
@@ -0,0 +1,159 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// alm_mont_inv_ct()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// almost Montgomery Inverse
+//
+// returns (k,r), r = (1/a)*(2^k) mod m
+//
+// (constant-execution-time version)
+*/
+int alm_mont_inv_ct(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME)
+{
+ const BNU_CHUNK_T* pm = MOD_MODULUS(pME);
+ int mLen = MOD_LEN(pME);
+ int modulusBitSize = MOD_BITSIZE(pME);
+
+ const int polLength = 6;
+ BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
+
+ BNU_CHUNK_T* pu = pBuffer;
+ BNU_CHUNK_T* ps = pu+mLen;
+ BNU_CHUNK_T* pv = ps+mLen;
+ BNU_CHUNK_T* pt = pv+mLen;
+
+ BNU_CHUNK_T* px = pt+mLen;
+ BNU_CHUNK_T* py = px+mLen;
+
+ int k = 0;
+ int i;
+ BNU_CHUNK_T ext = 0;
+
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
+
+ // u=modulus, s=1 and v=a, t=0,
+ COPY_BNU(pu, pm, mLen);
+ ZEXPAND_BNU(ps, 0, mLen); ps[0] = 1;
+ COPY_BNU(pv, pa, mLen);
+ ZEXPAND_BNU(pt, 0, mLen);
+
+ for(i=0; i<2*modulusBitSize; i++) {
+ /* update mask - update = (v==0)? 0xFF : 0 */
+ BNU_CHUNK_T update = ~cpIsGFpElemEquChunk_ct(pv, mLen, 0);
+ /* temporary masks */
+ BNU_CHUNK_T m, mm;
+
+ /* compute in advance r = s+t */
+ cpAdd_BNU(pr, ps, pt, mLen);
+
+ /*
+ // update or keep current u, s, v, t
+ */
+
+ /* if(isEven(u)) { u=u/2; s=2*s; } 1-st branch */
+ m = update & cpIsEven_ct(pu[0]);
+ cpLSR_BNU(px, pu, mLen, 1);
+ cpAdd_BNU(py, ps, ps, mLen);
+ cpMaskedReplace_ct(pu, px, mLen, m);
+ cpMaskedReplace_ct(ps, py, mLen, m);
+
+ /* else if(isEven(v)) { v=v/2; t=2*t; } 2-nd branch */
+ mm = update & ~m & cpIsEven_ct(pv[0]);
+ cpLSR_BNU(px, pv, mLen, 1);
+ cpAdd_BNU(py, pt, pt, mLen);
+ cpMaskedReplace_ct(pv, px, mLen, mm);
+ cpMaskedReplace_ct(pt, py, mLen, mm);
+
+ m |= mm; /* if fall in the 1-st of 2-nf branches m=FF.. else m=0 */
+
+ /* else if(v>=u) { v=(v-u)/2; s=s+t; t=2*t;} 3-st branch */
+ mm = cpSub_BNU(px, pv, pu, mLen);
+ mm = cpIsZero_ct(mm);
+ mm = update & ~m & mm;
+ cpLSR_BNU(px, px, mLen, 1);
+ ext += cpAdd_BNU(py, pt, pt, mLen) & mm;
+ cpMaskedReplace_ct(pv, px, mLen, mm);
+ cpMaskedReplace_ct(ps, pr, mLen, mm);
+ cpMaskedReplace_ct(pt, py, mLen, mm);
+
+ /* else { u=(u-v)/2; t= t+s; s=2*s; } 4-rd branch*/
+ cpSub_BNU(px, pu, pv, mLen);
+ mm = update & ~m & ~mm;
+ cpLSR_BNU(px, px, mLen, 1);
+ cpAdd_BNU(py, ps, ps, mLen);
+ cpMaskedReplace_ct(pu, px, mLen, mm);
+ cpMaskedReplace_ct(pt, pr, mLen, mm);
+ cpMaskedReplace_ct(ps, py, mLen, mm);
+
+ /* update or keep current k */
+ k = ((k+1) & update) | (k & ~update);
+ }
+
+ /*
+ // r = (t>mod)? t-mod : t;
+ // r = mod - t;
+ */
+ ext -= cpSub_BNU(pr, pt, pm, mLen);
+ cpMaskedReplace_ct(pr, pt, mLen, ~cpIsZero_ct(ext));
+ cpSub_BNU(pr, pm, pr, mLen);
+
+ /* test if inversion not found (k=0) */
+ k &= cpIsGFpElemEquChunk_ct(pu, mLen, 1);
+
+ gsModPoolFree(pME, polLength);
+ return k;
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_enginegetsize.c b/ext/ipp/sources/ippcp/gsmod_enginegetsize.c
new file mode 100644
index 0000000..89078fa
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_enginegetsize.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsModEngineGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+/*F*
+// Name: gsModEngineGetSize
+//
+// Purpose: Specifies size of size of ModEngine context (Montgomery).
+//
+// Returns: Reason:
+// ippStsLengthErr modulusBitSize < 1
+// numpe < MOD_ENGINE_MIN_POOL_SIZE
+// ippStsNoErr no errors
+//
+// Parameters:
+// numpe length of pool
+// modulusBitSize max modulus length (in bits)
+// pSize pointer to size
+//
+*F*/
+
+IppStatus gsModEngineGetSize(int modulusBitSize, int numpe, int* pSize)
+{
+ int modLen = BITS_BNU_CHUNK(modulusBitSize);
+ int pelmLen = BITS_BNU_CHUNK(modulusBitSize);
+
+ IPP_BADARG_RET(modulusBitSize<1, ippStsLengthErr);
+ IPP_BADARG_RET(numpe<MOD_ENGINE_MIN_POOL_SIZE, ippStsLengthErr);
+
+ /* allocates mimimal necessary to Montgomery based methods */
+ *pSize = sizeof(gsModEngine)
+ + modLen*sizeof(BNU_CHUNK_T) /* modulus */
+ + modLen*sizeof(BNU_CHUNK_T) /* mont_R */
+ + modLen*sizeof(BNU_CHUNK_T) /* mont_R^2 */
+ + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* buffers */
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_engineinit.c b/ext/ipp/sources/ippcp/gsmod_engineinit.c
new file mode 100644
index 0000000..31860eb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_engineinit.c
@@ -0,0 +1,131 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsModEngineInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+/*F*
+// Name: gsModEngineInit
+//
+// Purpose: Initialization of the ModEngine context (Montgomery)
+//
+// Returns: Reason:
+// ippStsLengthErr modulusBitSize < 1
+// numpe < MOD_ENGINE_MIN_POOL_SIZE
+// ippStsBadModulusErr (pModulus) && (pModulus[0] & 1) == 0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pME pointer to ModEngine
+// pModulus modulus
+// numpe length of pool
+// modulusBitSize max modulus length (in bits)
+// method ModMethod
+//
+*F*/
+
+IppStatus gsModEngineInit(gsModEngine* pME, const Ipp32u* pModulus, int modulusBitSize, int numpe, const gsModMethod* method)
+{
+ IPP_BADARG_RET(modulusBitSize<1, ippStsLengthErr);
+ IPP_BADARG_RET((pModulus) && (pModulus[0] & 1) == 0, ippStsBadModulusErr);
+ IPP_BADARG_RET(numpe<MOD_ENGINE_MIN_POOL_SIZE, ippStsLengthErr);
+
+/* convert bitsize nbits into the number of BNU_CHUNK_T */
+#define BITS_BNU_IPP32U(nbits) (((nbits)+31)/32)
+
+ {
+ int pelmLen = BITS_BNU_CHUNK(modulusBitSize);
+ int modLen = BITS_BNU_CHUNK(modulusBitSize);
+ int modLen32 = BITS_BNU_IPP32U(modulusBitSize);
+ Ipp8u* ptr = (Ipp8u*)pME;
+
+ /* clear whole context */
+ PaddBlock(0, pME, sizeof(gsModEngine));
+
+ MOD_PARENT(pME) = NULL;
+ MOD_EXTDEG(pME) = 1;
+ MOD_BITSIZE(pME) = modulusBitSize;
+ MOD_LEN(pME) = modLen;
+ MOD_PELEN(pME) = pelmLen;
+ MOD_METHOD(pME) = method;
+ MOD_MODULUS(pME) = (BNU_CHUNK_T*)(ptr += sizeof(gsModEngine));
+ MOD_MNT_R(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
+ MOD_MNT_R2(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
+ MOD_POOL_BUF(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
+ MOD_MAXPOOL(pME) = numpe;
+ MOD_USEDPOOL(pME) = 0;
+
+ if (pModulus) {
+ /* store modulus */
+ ZEXPAND_COPY_BNU((Ipp32u*)MOD_MODULUS(pME), modLen * (cpSize)(sizeof(BNU_CHUNK_T) / sizeof(Ipp32u)), pModulus, modLen32);
+
+ /* montgomery factor */
+ MOD_MNT_FACTOR(pME) = gsMontFactor(MOD_MODULUS(pME)[0]);
+
+ /* montgomery identity (R) */
+ ZEXPAND_BNU(MOD_MNT_R(pME), 0, modLen);
+ MOD_MNT_R(pME)[modLen] = 1;
+ cpMod_BNU(MOD_MNT_R(pME), modLen+1, MOD_MODULUS(pME), modLen);
+
+ /* montgomery domain converter (RR) */
+ ZEXPAND_BNU(MOD_MNT_R2(pME), 0, modLen);
+ COPY_BNU(MOD_MNT_R2(pME)+modLen, MOD_MNT_R(pME), modLen);
+ cpMod_BNU(MOD_MNT_R2(pME), 2*modLen, MOD_MODULUS(pME), modLen);
+ }
+ }
+
+#undef BITS_BNU_IPP32U
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_getpool.c b/ext/ipp/sources/ippcp/gsmod_getpool.c
new file mode 100644
index 0000000..fabc563
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_getpool.c
@@ -0,0 +1,63 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsModGetPool()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+BNU_CHUNK_T* gsModGetPool(gsModEngine* pME)
+{
+ BNU_CHUNK_T*
+ pPool = (pME->poolLenUsed >= pME->poolLen)? NULL : MOD_BUFFER(pME, pME->poolLenUsed);
+ return pPool;
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_inv.c b/ext/ipp/sources/ippcp/gsmod_inv.c
new file mode 100644
index 0000000..68a0501
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_inv.c
@@ -0,0 +1,93 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gs_inv()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// returns r =1/a
+// a in desidue domain
+// r in desidue domain
+*/
+BNU_CHUNK_T* gs_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME, alm_inv alm_inversion)
+{
+ int k = alm_inversion(pr, pa, pME);
+
+ if(0==k)
+ return NULL;
+
+ {
+ int mLen = MOD_LEN(pME);
+ int m = mLen*BNU_CHUNK_BITS;
+ mod_mul mon_mul = MOD_METHOD(pME)->mul;
+
+ BNU_CHUNK_T* t = gsModPoolAlloc(pME, 1);
+ //tbcd: temporary excluded: assert(NULL!=t);
+
+ if(k>m) {
+ ZEXPAND_BNU(t, 0, mLen);
+ t[0] = 1;
+ mon_mul(pr, pr, t, pME);
+ k -= m;
+ }
+ ZEXPAND_BNU(t, 0, mLen);
+ SET_BIT(t, m-k); /* t = 2^(m-k) */
+ mon_mul(pr, pr, t, pME);
+
+ gsModPoolFree(pME, 1);
+
+ return pr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_montfactor.c b/ext/ipp/sources/ippcp/gsmod_montfactor.c
new file mode 100644
index 0000000..02e1010
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_montfactor.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsMontFactor()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+/*
+// montfomery factor k0 = -((modulus^-1 mod B) %B)
+*/
+BNU_CHUNK_T gsMontFactor(BNU_CHUNK_T m0)
+{
+ BNU_CHUNK_T y = 1;
+ BNU_CHUNK_T x = 2;
+ BNU_CHUNK_T mask = 2*x-1;
+
+ int i;
+ for(i=2; i<=BNU_CHUNK_BITS; i++, x<<=1) {
+ BNU_CHUNK_T rH, rL;
+ MUL_AB(rH, rL, m0, y);
+ if( x < (rL & mask) ) /* x < ((m0*y) mod (2*x)) */
+ y+=x;
+ mask += mask + 1;
+ }
+ return 0-y;
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_montinv.c b/ext/ipp/sources/ippcp/gsmod_montinv.c
new file mode 100644
index 0000000..6d56a95
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_montinv.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gs_mont_inv()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcpmask_ct.h"
+
+__INLINE BNU_CHUNK_T* cpPow2_ct(int bit, BNU_CHUNK_T* dst, int len)
+{
+ int slot = bit/BNU_CHUNK_BITS;
+ BNU_CHUNK_T value = (BNU_CHUNK_T)1 << (bit%BNU_CHUNK_BITS);
+
+ int i;
+ len -= (int)cpIsEqu_ct(slot, len);
+ for(i=0; i<len; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(slot, i);
+ dst[i] = value & mask;
+ }
+
+ return dst;
+}
+
+/*
+// returns r = mont(a^-1)
+// a in desidue domain
+// r in Montgomery domain
+*/
+BNU_CHUNK_T* gs_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pME, alm_inv alm_inversion)
+{
+ int k = alm_inversion(pr, pa, pME);
+
+ if(0==k)
+ return NULL;
+
+ {
+ int mLen = MOD_LEN(pME);
+ int m = mLen*BNU_CHUNK_BITS;
+ mod_mul mon_mul = MOD_METHOD(pME)->mul;
+
+ BNU_CHUNK_T* t = gsModPoolAlloc(pME, 1);
+ //tbcd: temporary excluded: assert(NULL!=t);
+
+ if(k<=m) {
+ mon_mul(pr, pr, MOD_MNT_R2(pME), pME);
+ k += m;
+ }
+
+ //ZEXPAND_BNU(t, 0, mLen);
+ //SET_BIT(t, 2*m-k); /* t = 2^(2*m-k) */
+ cpPow2_ct(2*m-k, t, mLen);
+ mon_mul(pr, pr, t, pME);
+
+ gsModPoolFree(pME, 1);
+
+ return pr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_packctx.c b/ext/ipp/sources/ippcp/gsmod_packctx.c
new file mode 100644
index 0000000..599f5eb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_packctx.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsPackModEngineCtx()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+/*
+// Pack/Unpack methods
+*/
+void gsPackModEngineCtx(const gsModEngine* pCtx, Ipp8u* pBuffer)
+{
+ gsModEngine* pAlignedBuffer = (gsModEngine*)pBuffer;
+
+ /* max modulus length */
+ int modSize = MOD_LEN(pCtx);
+ /* size of context (bytes) without cube and pool buffers */
+ int ctxSize = sizeof(gsModEngine)
+ +sizeof(BNU_CHUNK_T)*(modSize*3);
+
+ CopyBlock(pCtx, pAlignedBuffer, ctxSize);
+ MOD_MODULUS(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MODULUS(pCtx))-IPP_UINT_PTR(pCtx));
+ MOD_MNT_R(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MNT_R(pCtx))-IPP_UINT_PTR(pCtx));
+ MOD_MNT_R2(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MNT_R2(pCtx))-IPP_UINT_PTR(pCtx));
+}
diff --git a/ext/ipp/sources/ippcp/gsmod_unpackctx.c b/ext/ipp/sources/ippcp/gsmod_unpackctx.c
new file mode 100644
index 0000000..575cc75
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmod_unpackctx.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. Modular Arithmetic Engine. General Functionality
+//
+// Contents:
+// gsUnpackModEngineCtx()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnuarith.h"
+#include "gsmodstuff.h"
+#include "pcptool.h"
+
+void gsUnpackModEngineCtx(const Ipp8u* pBuffer, gsModEngine* pCtx)
+{
+ gsModEngine* pAlignedBuffer = (gsModEngine*)pBuffer;
+
+ /* max modulus length */
+ int modSize = MOD_LEN(pAlignedBuffer);
+ /* size of context (bytes) without cube and pool buffers */
+ int ctxSize = sizeof(gsModEngine)
+ +sizeof(BNU_CHUNK_T)*(modSize*3);
+
+ CopyBlock(pAlignedBuffer, pCtx, ctxSize);
+ MOD_MODULUS(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MODULUS(pAlignedBuffer)));
+ MOD_MNT_R(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MNT_R(pAlignedBuffer)));
+ MOD_MNT_R2(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MNT_R2(pAlignedBuffer)));
+ MOD_POOL_BUF(pCtx) = MOD_MNT_R2(pCtx) + modSize;
+}
diff --git a/ext/ipp/sources/ippcp/gsmodmethod.c b/ext/ipp/sources/ippcp/gsmodmethod.c
new file mode 100644
index 0000000..74d1d1c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmodmethod.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include "gsmodmethodstuff.h"
+
+/*
+ methods
+*/
+
+static gsModMethod* gsModArith_C(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ gs_mont_decode,
+ gs_mont_mul,
+ gs_mont_sqr,
+ gs_mont_red,
+ gs_mont_add,
+ gs_mont_sub,
+ gs_mont_neg,
+ gs_mont_div2,
+ gs_mont_mul2,
+ gs_mont_mul3,
+ };
+ return &m;
+}
+#if (_IPP32E>=_IPP32E_L9)
+static gsModMethod* gsModArith_X(void)
+{
+ static gsModMethod m = {
+ gs_mont_encodeX,
+ gs_mont_decodeX,
+ gs_mont_mulX,
+ gs_mont_sqrX,
+ gs_mont_redX,
+ gs_mont_add,
+ gs_mont_sub,
+ gs_mont_neg,
+ gs_mont_div2,
+ gs_mont_mul2,
+ gs_mont_mul3,
+ };
+ return &m;
+}
+#endif
+
+gsModMethod* gsModArith(void)
+{
+ #if (_IPP32E>=_IPP32E_L9)
+ if(IsFeatureEnabled(ippCPUID_ADCOX))
+ return gsModArith_X();
+ else
+ #endif
+ return gsModArith_C();
+}
diff --git a/ext/ipp/sources/ippcp/src/gsmodmethod.h b/ext/ipp/sources/ippcp/gsmodmethod.h
index 4ce1d23..351337d 100644
--- a/ext/ipp/sources/ippcp/src/gsmodmethod.h
+++ b/ext/ipp/sources/ippcp/gsmodmethod.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
#if !defined(_GS_MOD_METHOD_H)
#define _GS_MOD_METHOD_H
diff --git a/ext/ipp/sources/ippcp/gsmodmethod_dlp.c b/ext/ipp/sources/ippcp/gsmodmethod_dlp.c
new file mode 100644
index 0000000..a811795
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmodmethod_dlp.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include "gsmodmethodstuff.h"
+
+/*
+ methods
+*/
+
+/* ******************************************** */
+
+static gsModMethod* gsModArithDLP_C(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ gs_mont_decode,
+ gs_mont_mul,
+ gs_mont_sqr,
+ gs_mont_red,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#if (_IPP32E>=_IPP32E_L9)
+static gsModMethod* gsModArithDLP_X(void)
+{
+ static gsModMethod m = {
+ gs_mont_encodeX,
+ gs_mont_decodeX,
+ gs_mont_mulX,
+ gs_mont_sqrX,
+ gs_mont_redX,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#endif
+
+gsModMethod* gsModArithDLP(void)
+{
+ #if (_IPP32E>=_IPP32E_L9)
+ if(IsFeatureEnabled(ippCPUID_ADCOX))
+ return gsModArithDLP_X();
+ else
+ #endif
+ return gsModArithDLP_C();
+}
+/* ******************************************** */
diff --git a/ext/ipp/sources/ippcp/gsmodmethod_gfp.c b/ext/ipp/sources/ippcp/gsmodmethod_gfp.c
new file mode 100644
index 0000000..696ac8e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmodmethod_gfp.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include "gsmodmethodstuff.h"
+
+/*
+ methods
+*/
+
+/* ******************************************** */
+
+static gsModMethod* gsArithGFp_C(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ gs_mont_decode,
+ gs_mont_mul,
+ gs_mont_sqr,
+ NULL,
+ gs_mont_add,
+ gs_mont_sub,
+ gs_mont_neg,
+ gs_mont_div2,
+ gs_mont_mul2,
+ gs_mont_mul3,
+ };
+ return &m;
+}
+#if (_IPP32E>=_IPP32E_L9)
+static gsModMethod* gsArithGFp_X(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ gs_mont_decode,
+ gs_mont_mul,
+ gs_mont_sqr,
+ NULL,
+ gs_mont_add,
+ gs_mont_sub,
+ gs_mont_neg,
+ gs_mont_div2,
+ gs_mont_mul2,
+ gs_mont_mul3,
+ };
+ return &m;
+}
+#endif
+
+gsModMethod* gsArithGFp(void)
+{
+ #if (_IPP32E>=_IPP32E_L9)
+ if(IsFeatureEnabled(ippCPUID_ADCOX))
+ return gsArithGFp_X();
+ else
+ #endif
+ return gsArithGFp_C();
+}
diff --git a/ext/ipp/sources/ippcp/gsmodmethod_mont.c b/ext/ipp/sources/ippcp/gsmodmethod_mont.c
new file mode 100644
index 0000000..5cad1af
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmodmethod_mont.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include "gsmodmethodstuff.h"
+
+/*
+ methods
+*/
+
+/* ******************************************** */
+
+static gsModMethod* gsModArithMont_C(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ NULL,
+ gs_mont_mul,
+ gs_mont_sqr,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#if (_IPP32E>=_IPP32E_L9)
+static gsModMethod* gsModArithMont_X(void)
+{
+ static gsModMethod m = {
+ gs_mont_encodeX,
+ NULL,
+ gs_mont_mulX,
+ gs_mont_sqrX,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#endif
+
+gsModMethod* gsModArithMont(void)
+{
+ #if (_IPP32E>=_IPP32E_L9)
+ if(IsFeatureEnabled(ippCPUID_ADCOX))
+ return gsModArithMont_X();
+ else
+ #endif
+ return gsModArithMont_C();
+}
+/* ******************************************** */
diff --git a/ext/ipp/sources/ippcp/gsmodmethod_rsa.c b/ext/ipp/sources/ippcp/gsmodmethod_rsa.c
new file mode 100644
index 0000000..f525a90
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsmodmethod_rsa.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include "gsmodmethodstuff.h"
+
+/*
+ methods
+*/
+
+/* ******************************************** */
+
+static gsModMethod* gsModArithRSA_C(void)
+{
+ static gsModMethod m = {
+ gs_mont_encode,
+ gs_mont_decode,
+ gs_mont_mul,
+ gs_mont_sqr,
+ gs_mont_red,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#if (_IPP32E>=_IPP32E_L9)
+static gsModMethod* gsModArithRSA_X(void)
+{
+ static gsModMethod m = {
+ gs_mont_encodeX,
+ gs_mont_decodeX,
+ gs_mont_mulX,
+ gs_mont_sqrX,
+ gs_mont_redX,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ };
+ return &m;
+}
+#endif
+
+gsModMethod* gsModArithRSA(void)
+{
+ #if (_IPP32E>=_IPP32E_L9)
+ if(IsFeatureEnabled(ippCPUID_ADCOX))
+ return gsModArithRSA_X();
+ else
+ #endif
+ return gsModArithRSA_C();
+}
+/* ******************************************** */
diff --git a/ext/ipp/sources/ippcp/src/gsmodmethod.c b/ext/ipp/sources/ippcp/gsmodmethodstuff.h
index 426c5ad..f7454d7 100644
--- a/ext/ipp/sources/ippcp/src/gsmodmethod.c
+++ b/ext/ipp/sources/ippcp/gsmodmethodstuff.h
@@ -1,18 +1,45 @@
-/*############################################################################
- # Copyright 2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#if !defined(_GS_MOD_METHOD_STUFF_H)
+#define _GS_MOD_METHOD_STUFF_H
#include "owndefs.h"
#include "owncp.h"
@@ -23,7 +50,7 @@
#include "gsmodmethod.h"
#include "pcpmontred.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
/* r = (a+m) mod m */
/*
@@ -40,7 +67,7 @@ static BNU_CHUNK_T* gs_mont_add(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, const BN
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
{
BNU_CHUNK_T extension = cpAdd_BNU(pr, pa, pb, mLen);
extension -= cpSub_BNU(pBuffer, pr, pm, mLen);
@@ -65,7 +92,7 @@ static BNU_CHUNK_T* gs_mont_sub(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, const BN
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
{
BNU_CHUNK_T extension = cpSub_BNU(pr, pa, pb, mLen);
cpAdd_BNU(pBuffer, pr, pm, mLen);
@@ -89,7 +116,7 @@ static BNU_CHUNK_T* gs_mont_neg(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEng
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
{
BNU_CHUNK_T extension = cpSub_BNU(pr, pm, pa, mLen);
extension -= cpSub_BNU(pBuffer, pr, pm, mLen);
@@ -113,7 +140,7 @@ static BNU_CHUNK_T* gs_mont_div2(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEn
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
{
cpSize i;
BNU_CHUNK_T mask = 0 - (pa[0]&1);
@@ -151,7 +178,7 @@ static BNU_CHUNK_T* gs_mont_mul3(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEn
{
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
gs_mont_add(pBuffer, pa, pa, pME);
gs_mont_add(pr, pa, pBuffer, pME);
@@ -252,7 +279,7 @@ static BNU_CHUNK_T* gs_mont_mul(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, const BN
const int polLength = 1;
BNU_CHUNK_T* pBuffer = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pBuffer);
+ //tbcd: temporary excluded: assert(NULL!=pBuffer);
{
BNU_CHUNK_T carry = 0;
@@ -317,7 +344,7 @@ static BNU_CHUNK_T* gs_mont_mul(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, const BN
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpMulAdc_BNU_school(pProduct, pa,mLen, pb,mLen);
cpMontRedAdc_BNU(pr, pProduct, pm, mLen, m0);
@@ -335,7 +362,7 @@ static BNU_CHUNK_T* gs_mont_mulX(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, const B
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpMulAdx_BNU_school(pProduct, pa,mLen, pb,mLen);
cpMontRedAdx_BNU(pr, pProduct, pm, mLen, m0);
@@ -362,7 +389,7 @@ static BNU_CHUNK_T* gs_mont_sqr(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEng
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpSqrAdc_BNU_school(pProduct, pa,mLen);
cpMontRedAdc_BNU(pr, pProduct, pm, mLen, m0);
@@ -380,7 +407,7 @@ static BNU_CHUNK_T* gs_mont_sqrX(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEn
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpSqrAdx_BNU_school(pProduct, pa,mLen);
cpMontRedAdx_BNU(pr, pProduct, pm, mLen, m0);
@@ -406,7 +433,7 @@ static BNU_CHUNK_T* gs_mont_encode(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsMod
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpMulAdc_BNU_school(pProduct, pa,mLen, MOD_MNT_R2(pME),mLen);
cpMontRedAdc_BNU(pr, pProduct, pm, mLen, m0);
@@ -425,7 +452,7 @@ static BNU_CHUNK_T* gs_mont_encodeX(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsMo
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
cpMulAdx_BNU_school(pProduct, pa,mLen, MOD_MNT_R2(pME),mLen);
cpMontRedAdx_BNU(pr, pProduct, pm, mLen, m0);
@@ -448,7 +475,7 @@ static BNU_CHUNK_T* gs_mont_decode(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsMod
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
ZEXPAND_COPY_BNU(pProduct, 2*mLen, pa, mLen);
cpMontRedAdc_BNU(pr, pProduct, MOD_MODULUS(pME), mLen, MOD_MNT_FACTOR(pME));
@@ -464,7 +491,7 @@ static BNU_CHUNK_T* gs_mont_decodeX(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsMo
const int polLength = 2;
BNU_CHUNK_T* pProduct = gsModPoolAlloc(pME, polLength);
- //gres: temporary excluded: assert(NULL!=pProduct);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
ZEXPAND_COPY_BNU(pProduct, 2*mLen, pa, mLen);
cpMontRedAdx_BNU(pr, pProduct, MOD_MODULUS(pME), mLen, MOD_MNT_FACTOR(pME));
@@ -474,246 +501,5 @@ static BNU_CHUNK_T* gs_mont_decodeX(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsMo
}
#endif
+#endif /* _GS_MOD_METHOD_STUFF_H */
-/*
- methods
-*/
-
-static gsModMethod* gsModArith_C(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- gs_mont_decode,
- gs_mont_mul,
- gs_mont_sqr,
- gs_mont_red,
- gs_mont_add,
- gs_mont_sub,
- gs_mont_neg,
- gs_mont_div2,
- gs_mont_mul2,
- gs_mont_mul3,
- };
- return &m;
-}
-#if (_IPP32E>=_IPP32E_L9)
-static gsModMethod* gsModArith_X(void)
-{
- static gsModMethod m = {
- gs_mont_encodeX,
- gs_mont_decodeX,
- gs_mont_mulX,
- gs_mont_sqrX,
- gs_mont_redX,
- gs_mont_add,
- gs_mont_sub,
- gs_mont_neg,
- gs_mont_div2,
- gs_mont_mul2,
- gs_mont_mul3,
- };
- return &m;
-}
-#endif
-
-gsModMethod* gsModArith(void)
-{
- #if (_IPP32E>=_IPP32E_L9)
- if(IsFeatureEnabled(ADCOX_ENABLED))
- return gsModArith_X();
- else
- #endif
- return gsModArith_C();
-}
-/* ******************************************** */
-
-static gsModMethod* gsModArithRSA_C(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- gs_mont_decode,
- gs_mont_mul,
- gs_mont_sqr,
- gs_mont_red,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#if (_IPP32E>=_IPP32E_L9)
-static gsModMethod* gsModArithRSA_X(void)
-{
- static gsModMethod m = {
- gs_mont_encodeX,
- gs_mont_decodeX,
- gs_mont_mulX,
- gs_mont_sqrX,
- gs_mont_redX,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#endif
-
-gsModMethod* gsModArithRSA(void)
-{
- #if (_IPP32E>=_IPP32E_L9)
- if(IsFeatureEnabled(ADCOX_ENABLED))
- return gsModArithRSA_X();
- else
- #endif
- return gsModArithRSA_C();
-}
-/* ******************************************** */
-
-static gsModMethod* gsModArithMont_C(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- NULL,
- gs_mont_mul,
- gs_mont_sqr,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#if (_IPP32E>=_IPP32E_L9)
-static gsModMethod* gsModArithMont_X(void)
-{
- static gsModMethod m = {
- gs_mont_encodeX,
- NULL,
- gs_mont_mulX,
- gs_mont_sqrX,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#endif
-
-gsModMethod* gsModArithMont(void)
-{
- #if (_IPP32E>=_IPP32E_L9)
- if(IsFeatureEnabled(ADCOX_ENABLED))
- return gsModArithMont_X();
- else
- #endif
- return gsModArithMont_C();
-}
-/* ******************************************** */
-
-static gsModMethod* gsModArithDLP_C(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- gs_mont_decode,
- gs_mont_mul,
- gs_mont_sqr,
- gs_mont_red,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#if (_IPP32E>=_IPP32E_L9)
-static gsModMethod* gsModArithDLP_X(void)
-{
- static gsModMethod m = {
- gs_mont_encodeX,
- gs_mont_decodeX,
- gs_mont_mulX,
- gs_mont_sqrX,
- gs_mont_redX,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
- return &m;
-}
-#endif
-
-gsModMethod* gsModArithDLP(void)
-{
- #if (_IPP32E>=_IPP32E_L9)
- if(IsFeatureEnabled(ADCOX_ENABLED))
- return gsModArithDLP_X();
- else
- #endif
- return gsModArithDLP_C();
-}
-/* ******************************************** */
-
-static gsModMethod* gsArithGFp_C(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- gs_mont_decode,
- gs_mont_mul,
- gs_mont_sqr,
- NULL,
- gs_mont_add,
- gs_mont_sub,
- gs_mont_neg,
- gs_mont_div2,
- gs_mont_mul2,
- gs_mont_mul3,
- };
- return &m;
-}
-#if (_IPP32E>=_IPP32E_L9)
-static gsModMethod* gsArithGFp_X(void)
-{
- static gsModMethod m = {
- gs_mont_encode,
- gs_mont_decode,
- gs_mont_mul,
- gs_mont_sqr,
- NULL,
- gs_mont_add,
- gs_mont_sub,
- gs_mont_neg,
- gs_mont_div2,
- gs_mont_mul2,
- gs_mont_mul3,
- };
- return &m;
-}
-#endif
-
-gsModMethod* gsArithGFp(void)
-{
- #if (_IPP32E>=_IPP32E_L9)
- if(IsFeatureEnabled(ADCOX_ENABLED))
- return gsArithGFp_X();
- else
- #endif
- return gsArithGFp_C();
-}
diff --git a/ext/ipp/sources/ippcp/src/gsmodstuff.h b/ext/ipp/sources/ippcp/gsmodstuff.h
index 02498ad..c395fc2 100644
--- a/ext/ipp/sources/ippcp/src/gsmodstuff.h
+++ b/ext/ipp/sources/ippcp/gsmodstuff.h
@@ -1,18 +1,43 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
#if !defined(_GS_MOD_STUFF_H)
#define _GS_MOD_STUFF_H
@@ -85,11 +110,21 @@ BNU_CHUNK_T gsMontFactor(BNU_CHUNK_T m0);
/*
// pool management methods
*/
-//#define gsModPoolAlloc OWNAPI(gsModPoolAlloc)
-//BNU_CHUNK_T* gsModPoolAlloc(gsModEngine* pME, int poolLen);
-//#define gsModPoolFree OWNAPI(gsModPoolFree)
-//void gsModPoolFree(gsModEngine* pME, int poolLen);
+/*F*
+// Name: gsModPoolAlloc
+//
+// Purpose: Allocation pool.
+//
+// Returns: Reason:
+// pointer to allocate Pool enough of pool
+// NULL required pool more than pME have
+//
+// Parameters:
+// pME ModEngine
+// poolReq Required pool
+*F*/
+
__INLINE BNU_CHUNK_T* gsModPoolAlloc(gsModEngine* pME, int poolReq)
{
BNU_CHUNK_T* pPool = MOD_BUFFER(pME, pME->poolLenUsed);
@@ -102,6 +137,19 @@ __INLINE BNU_CHUNK_T* gsModPoolAlloc(gsModEngine* pME, int poolReq)
return pPool;
}
+/*F*
+// Name: gsModPoolFree
+//
+// Purpose: Delete pool.
+//
+// Returns:
+// nothing
+//
+// Parameters:
+// pME ModEngine
+// poolReq Required pool
+*F*/
+
__INLINE void gsModPoolFree(gsModEngine* pME, int poolReq)
{
if(pME->poolLenUsed < poolReq)
@@ -116,14 +164,19 @@ BNU_CHUNK_T* gsModGetPool(gsModEngine* pME);
/*
// advanced operations
*/
+typedef int (*alm_inv)(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA);
+
#define alm_mont_inv OWNAPI(alm_mont_inv)
int alm_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA);
+#define alm_mont_inv_ct OWNAPI(alm_mont_inv_ct)
+int alm_mont_inv_ct(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA);
+
#define gs_mont_inv OWNAPI(gs_mont_inv)
-BNU_CHUNK_T* gs_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA);
+BNU_CHUNK_T* gs_mont_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA, alm_inv invf);
#define gs_inv OWNAPI(gs_inv)
-BNU_CHUNK_T* gs_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA);
+BNU_CHUNK_T* gs_inv(BNU_CHUNK_T* pr, const BNU_CHUNK_T* pa, gsModEngine* pMA, alm_inv invf);
/*
// Pack/Unpack methods
diff --git a/ext/ipp/sources/ippcp/gsscramble.c b/ext/ipp/sources/ippcp/gsscramble.c
new file mode 100644
index 0000000..646fd34
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsscramble.c
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Fixed window exponentiation scramble/unscramble
+//
+// Contents:
+// gsScramblePut()
+// gsScrambleGet()
+// gsScrambleGet_sscm()
+//
+*/
+#include "owncp.h"
+#include "gsscramble.h"
+#include "pcpmask_ct.h"
+
+int gsGetScrambleBufferSize(int modulusLen, int w)
+{
+ /* size of resource to store 2^w values of modulusLen*sizeof(BNU_CHUNK_T) each */
+ int size = (1<<w) * modulusLen * sizeof(BNU_CHUNK_T);
+ /* padd it up to CACHE_LINE_SIZE */
+ size += (CACHE_LINE_SIZE - (size % CACHE_LINE_SIZE)) %CACHE_LINE_SIZE;
+ return size/sizeof(BNU_CHUNK_T);
+}
+
+void gsScramblePut(BNU_CHUNK_T* tbl, int idx, const BNU_CHUNK_T* val, int vLen, int w)
+{
+ int width = 1 << w;
+ int i, j;
+ for(i=0, j=idx; i<vLen; i++, j+= width) {
+ tbl[j] = val[i];
+ }
+}
+
+void gsScrambleGet(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w)
+{
+ int width = 1 << w;
+ int i, j;
+ for(i=0, j=idx; i<vLen; i++, j+= width) {
+ val[i] = tbl[j];
+ }
+}
+
+void gsScrambleGet_sscm(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w)
+{
+ BNU_CHUNK_T mask[1<<MAX_W];
+
+ int width = 1 << w;
+
+ int n, i;
+ switch (w) {
+ case 6:
+ for(n=0; n<(1<<6); n++)
+ mask[n] = cpIsEqu_ct(n, idx);
+ break;
+ case 5:
+ for(n=0; n<(1<<5); n++)
+ mask[n] = cpIsEqu_ct(n, idx);
+ break;
+ case 4:
+ for(n=0; n<(1<<4); n++)
+ mask[n] = cpIsEqu_ct(n, idx);
+ break;
+ case 3:
+ for(n=0; n<(1<<3); n++)
+ mask[n] = cpIsEqu_ct(n, idx);
+ break;
+ case 2:
+ for(n=0; n<(1<<2); n++)
+ mask[n] = cpIsEqu_ct(n, idx);
+ break;
+ default:
+ mask[0] = cpIsEqu_ct(0, idx);
+ mask[1] = cpIsEqu_ct(1, idx);
+ break;
+ }
+
+ for(i=0; i<vLen; i++, tbl += width) {
+ BNU_CHUNK_T acc = 0;
+
+ switch (w) {
+ case 6:
+ for(n=0; n<(1<<6); n++)
+ acc |= tbl[n] & mask[n];
+ break;
+ case 5:
+ for(n=0; n<(1<<5); n++)
+ acc |= tbl[n] & mask[n];
+ break;
+ case 4:
+ for(n=0; n<(1<<4); n++)
+ acc |= tbl[n] & mask[n];
+ break;
+ case 3:
+ for(n=0; n<(1<<3); n++)
+ acc |= tbl[n] & mask[n];
+ break;
+ case 2:
+ for(n=0; n<(1<<2); n++)
+ acc |= tbl[n] & mask[n];
+ break;
+ default:
+ acc |= tbl[0] & mask[0];
+ acc |= tbl[1] & mask[1];
+ break;
+ }
+
+ val[i] = acc;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/gsscramble.h b/ext/ipp/sources/ippcp/gsscramble.h
new file mode 100644
index 0000000..32eb60f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/gsscramble.h
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Fixed window exponentiation scramble/unscramble
+//
+// Contents:
+// gsGetScrambleBufferSize()
+// gsScramblePut()
+// gsScrambleGet()
+// gsScrambleGet_sscm()
+//
+//
+*/
+
+#if !defined(_GS_SCRAMBLE_H)
+#define _GS_SCRAMBLE_H
+
+#include "pcpbnuimpl.h"
+
+#define MAX_W (6)
+
+#define gsGetScrambleBufferSize OWNAPI(gsGetScrambleBufferSize)
+int gsGetScrambleBufferSize(int modulusLen, int w);
+
+#define gsScramblePut OWNAPI(gsScramblePut)
+void gsScramblePut(BNU_CHUNK_T* tbl, int idx, const BNU_CHUNK_T* val, int vLen, int w);
+
+#define gsScrambleGet OWNAPI(gsScrambleGet)
+void gsScrambleGet(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w);
+
+#define gsScrambleGet_sscm OWNAPI(gsScrambleGet_sscm)
+void gsScrambleGet_sscm(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w);
+
+#endif /* _GS_SCRAMBLE_H */
diff --git a/ext/ipp/sources/ippcp/ippcp.def b/ext/ipp/sources/ippcp/ippcp.def
new file mode 100644
index 0000000..763c87e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/ippcp.def
@@ -0,0 +1,509 @@
+EXPORTS
+
+ippcpGetLibVersion
+ippcpInit
+cpGetReg
+cpStartTscp
+cpStopTscp
+cpStartTsc
+cpStopTsc
+cpGetCacheSize
+ippcpSetCpuFeatures
+ippcpGetCpuFeatures
+ippcpGetCpuClocks
+ippcpSetNumThreads
+ippcpGetNumThreads
+ippcpGetEnabledCpuFeatures
+ippcpGetEnabledNumThreads
+ippcpGetStatusString
+ippsDESGetSize
+ippsDESInit
+ippsDESPack
+ippsDESUnpack
+ippsTDESEncryptECB
+ippsTDESDecryptECB
+ippsTDESEncryptCBC
+ippsTDESDecryptCBC
+ippsTDESEncryptCFB
+ippsTDESDecryptCFB
+ippsTDESEncryptOFB
+ippsTDESDecryptOFB
+ippsTDESEncryptCTR
+ippsTDESDecryptCTR
+ippsAESGetSize
+ippsAESInit
+ippsAESSetKey
+ippsAESPack
+ippsAESUnpack
+ippsAESEncryptECB
+ippsAESDecryptECB
+ippsAESEncryptCBC
+ippsAESEncryptCBC_CS1
+ippsAESEncryptCBC_CS2
+ippsAESEncryptCBC_CS3
+ippsAESDecryptCBC
+ippsAESDecryptCBC_CS1
+ippsAESDecryptCBC_CS2
+ippsAESDecryptCBC_CS3
+ippsAESEncryptCFB
+ippsAESDecryptCFB
+ippsAESEncryptOFB
+ippsAESDecryptOFB
+ippsAESEncryptCTR
+ippsAESDecryptCTR
+ippsAESEncryptXTS_Direct
+ippsAESDecryptXTS_Direct
+ippsSMS4GetSize
+ippsSMS4Init
+ippsSMS4SetKey
+ippsSMS4EncryptECB
+ippsSMS4DecryptECB
+ippsSMS4EncryptCBC
+ippsSMS4EncryptCBC_CS1
+ippsSMS4EncryptCBC_CS2
+ippsSMS4EncryptCBC_CS3
+ippsSMS4DecryptCBC
+ippsSMS4DecryptCBC_CS1
+ippsSMS4DecryptCBC_CS2
+ippsSMS4DecryptCBC_CS3
+ippsSMS4EncryptCFB
+ippsSMS4DecryptCFB
+ippsSMS4EncryptOFB
+ippsSMS4DecryptOFB
+ippsSMS4EncryptCTR
+ippsSMS4DecryptCTR
+ippsSMS4_CCMGetSize
+ippsSMS4_CCMInit
+ippsSMS4_CCMMessageLen
+ippsSMS4_CCMTagLen
+ippsSMS4_CCMStart
+ippsSMS4_CCMEncrypt
+ippsSMS4_CCMDecrypt
+ippsSMS4_CCMGetTag
+ippsAES_CCMGetSize
+ippsAES_CCMInit
+ippsAES_CCMMessageLen
+ippsAES_CCMTagLen
+ippsAES_CCMStart
+ippsAES_CCMEncrypt
+ippsAES_CCMDecrypt
+ippsAES_CCMGetTag
+ippsAES_GCMGetSize
+ippsAES_GCMInit
+ippsAES_GCMReset
+ippsAES_GCMProcessIV
+ippsAES_GCMProcessAAD
+ippsAES_GCMStart
+ippsAES_GCMEncrypt
+ippsAES_GCMDecrypt
+ippsAES_GCMGetTag
+ippsAES_XTSGetSize
+ippsAES_XTSInit
+ippsAES_XTSEncrypt
+ippsAES_XTSDecrypt
+ippsAES_S2V_CMAC
+ippsAES_SIVEncrypt
+ippsAES_SIVDecrypt
+ippsAES_CMACGetSize
+ippsAES_CMACInit
+ippsAES_CMACUpdate
+ippsAES_CMACFinal
+ippsAES_CMACGetTag
+ippsARCFourCheckKey
+ippsARCFourGetSize
+ippsARCFourInit
+ippsARCFourReset
+ippsARCFourPack
+ippsARCFourUnpack
+ippsARCFourEncrypt
+ippsARCFourDecrypt
+ippsSHA1GetSize
+ippsSHA1Init
+ippsSHA1Duplicate
+ippsSHA1Pack
+ippsSHA1Unpack
+ippsSHA1Update
+ippsSHA1GetTag
+ippsSHA1Final
+ippsSHA1MessageDigest
+ippsSHA224GetSize
+ippsSHA224Init
+ippsSHA224Duplicate
+ippsSHA224Pack
+ippsSHA224Unpack
+ippsSHA224Update
+ippsSHA224GetTag
+ippsSHA224Final
+ippsSHA224MessageDigest
+ippsSHA256GetSize
+ippsSHA256Init
+ippsSHA256Duplicate
+ippsSHA256Pack
+ippsSHA256Unpack
+ippsSHA256Update
+ippsSHA256GetTag
+ippsSHA256Final
+ippsSHA256MessageDigest
+ippsSHA384GetSize
+ippsSHA384Init
+ippsSHA384Duplicate
+ippsSHA384Pack
+ippsSHA384Unpack
+ippsSHA384Update
+ippsSHA384GetTag
+ippsSHA384Final
+ippsSHA384MessageDigest
+ippsSHA512GetSize
+ippsSHA512Init
+ippsSHA512Duplicate
+ippsSHA512Pack
+ippsSHA512Unpack
+ippsSHA512Update
+ippsSHA512GetTag
+ippsSHA512Final
+ippsSHA512MessageDigest
+ippsMD5GetSize
+ippsMD5Init
+ippsMD5Duplicate
+ippsMD5Pack
+ippsMD5Unpack
+ippsMD5Update
+ippsMD5GetTag
+ippsMD5Final
+ippsMD5MessageDigest
+ippsSM3GetSize
+ippsSM3Init
+ippsSM3Duplicate
+ippsSM3Pack
+ippsSM3Unpack
+ippsSM3Update
+ippsSM3GetTag
+ippsSM3Final
+ippsSM3MessageDigest
+ippsHashGetSize
+ippsHashInit
+ippsHashPack
+ippsHashUnpack
+ippsHashDuplicate
+ippsHashUpdate
+ippsHashGetTag
+ippsHashFinal
+ippsHashMessage
+ippsHashMethod_MD5
+ippsHashMethod_SM3
+ippsHashMethod_SHA1
+ippsHashMethod_SHA1_NI
+ippsHashMethod_SHA1_TT
+ippsHashMethod_SHA256
+ippsHashMethod_SHA256_NI
+ippsHashMethod_SHA256_TT
+ippsHashMethod_SHA224
+ippsHashMethod_SHA224_NI
+ippsHashMethod_SHA224_TT
+ippsHashMethod_SHA512
+ippsHashMethod_SHA384
+ippsHashMethod_SHA512_256
+ippsHashMethod_SHA512_224
+ippsHashGetSize_rmf
+ippsHashInit_rmf
+ippsHashPack_rmf
+ippsHashUnpack_rmf
+ippsHashDuplicate_rmf
+ippsHashUpdate_rmf
+ippsHashGetTag_rmf
+ippsHashFinal_rmf
+ippsHashMessage_rmf
+ippsMGF
+ippsMGF1_rmf
+ippsMGF2_rmf
+ippsHMAC_GetSize
+ippsHMAC_Init
+ippsHMAC_Pack
+ippsHMAC_Unpack
+ippsHMAC_Duplicate
+ippsHMAC_Update
+ippsHMAC_Final
+ippsHMAC_GetTag
+ippsHMAC_Message
+ippsHMACGetSize_rmf
+ippsHMACInit_rmf
+ippsHMACPack_rmf
+ippsHMACUnpack_rmf
+ippsHMACDuplicate_rmf
+ippsHMACUpdate_rmf
+ippsHMACFinal_rmf
+ippsHMACGetTag_rmf
+ippsHMACMessage_rmf
+ippsBigNumGetSize
+ippsBigNumInit
+ippsCmpZero_BN
+ippsCmp_BN
+ippsGetSize_BN
+ippsSet_BN
+ippsGet_BN
+ippsRef_BN
+ippsExtGet_BN
+ippsAdd_BN
+ippsSub_BN
+ippsMul_BN
+ippsMAC_BN_I
+ippsDiv_BN
+ippsMod_BN
+ippsGcd_BN
+ippsModInv_BN
+ippsSetOctString_BN
+ippsGetOctString_BN
+ippsMontGetSize
+ippsMontInit
+ippsMontSet
+ippsMontGet
+ippsMontForm
+ippsMontMul
+ippsMontExp
+ippsPRNGGetSize
+ippsPRNGInit
+ippsPRNGSetModulus
+ippsPRNGSetH0
+ippsPRNGSetAugment
+ippsPRNGSetSeed
+ippsPRNGGetSeed
+ippsPRNGen
+ippsPRNGen_BN
+ippsPRNGenRDRAND
+ippsPRNGenRDRAND_BN
+ippsTRNGenRDSEED
+ippsTRNGenRDSEED_BN
+ippsPrimeGetSize
+ippsPrimeInit
+ippsPrimeGen
+ippsPrimeTest
+ippsPrimeGen_BN
+ippsPrimeTest_BN
+ippsPrimeGet
+ippsPrimeGet_BN
+ippsPrimeSet
+ippsPrimeSet_BN
+ippsRSA_GetSizePublicKey
+ippsRSA_InitPublicKey
+ippsRSA_SetPublicKey
+ippsRSA_GetPublicKey
+ippsRSA_GetSizePrivateKeyType1
+ippsRSA_InitPrivateKeyType1
+ippsRSA_SetPrivateKeyType1
+ippsRSA_GetPrivateKeyType1
+ippsRSA_GetSizePrivateKeyType2
+ippsRSA_InitPrivateKeyType2
+ippsRSA_SetPrivateKeyType2
+ippsRSA_GetPrivateKeyType2
+ippsRSA_GetBufferSizePublicKey
+ippsRSA_GetBufferSizePrivateKey
+ippsRSA_Encrypt
+ippsRSA_Decrypt
+ippsRSA_GenerateKeys
+ippsRSA_ValidateKeys
+ippsRSAEncrypt_OAEP
+ippsRSADecrypt_OAEP
+ippsRSAEncrypt_OAEP_rmf
+ippsRSADecrypt_OAEP_rmf
+ippsRSAEncrypt_PKCSv15
+ippsRSADecrypt_PKCSv15
+ippsRSASign_PSS
+ippsRSAVerify_PSS
+ippsRSASign_PSS_rmf
+ippsRSAVerify_PSS_rmf
+ippsRSASign_PKCS1v15
+ippsRSAVerify_PKCS1v15
+ippsRSASign_PKCS1v15_rmf
+ippsRSAVerify_PKCS1v15_rmf
+ippsDLGetResultString
+ippsDLPGetSize
+ippsDLPInit
+ippsDLPPack
+ippsDLPUnpack
+ippsDLPSet
+ippsDLPGet
+ippsDLPSetDP
+ippsDLPGetDP
+ippsDLPGenKeyPair
+ippsDLPPublicKey
+ippsDLPValidateKeyPair
+ippsDLPSetKeyPair
+ippsDLPSignDSA
+ippsDLPVerifyDSA
+ippsDLPSharedSecretDH
+ippsDLPGenerateDSA
+ippsDLPValidateDSA
+ippsDLPGenerateDH
+ippsDLPValidateDH
+ippsECCGetResultString
+ippsECCPGetSize
+ippsECCPGetSizeStd128r1
+ippsECCPGetSizeStd128r2
+ippsECCPGetSizeStd192r1
+ippsECCPGetSizeStd224r1
+ippsECCPGetSizeStd256r1
+ippsECCPGetSizeStd384r1
+ippsECCPGetSizeStd521r1
+ippsECCPGetSizeStdSM2
+ippsECCPInit
+ippsECCPInitStd128r1
+ippsECCPInitStd128r2
+ippsECCPInitStd192r1
+ippsECCPInitStd224r1
+ippsECCPInitStd256r1
+ippsECCPInitStd384r1
+ippsECCPInitStd521r1
+ippsECCPInitStdSM2
+ippsECCPSet
+ippsECCPSetStd
+ippsECCPSetStd128r1
+ippsECCPSetStd128r2
+ippsECCPSetStd192r1
+ippsECCPSetStd224r1
+ippsECCPSetStd256r1
+ippsECCPSetStd384r1
+ippsECCPSetStd521r1
+ippsECCPSetStdSM2
+ippsECCPBindGxyTblStd192r1
+ippsECCPBindGxyTblStd224r1
+ippsECCPBindGxyTblStd256r1
+ippsECCPBindGxyTblStd384r1
+ippsECCPBindGxyTblStd521r1
+ippsECCPBindGxyTblStdSM2
+ippsECCPGet
+ippsECCPGetOrderBitSize
+ippsECCPValidate
+ippsECCPPointGetSize
+ippsECCPPointInit
+ippsECCPSetPoint
+ippsECCPSetPointAtInfinity
+ippsECCPGetPoint
+ippsECCPCheckPoint
+ippsECCPComparePoint
+ippsECCPNegativePoint
+ippsECCPAddPoint
+ippsECCPMulPointScalar
+ippsECCPGenKeyPair
+ippsECCPPublicKey
+ippsECCPValidateKeyPair
+ippsECCPSetKeyPair
+ippsECCPSharedSecretDH
+ippsECCPSharedSecretDHC
+ippsECCPSignDSA
+ippsECCPVerifyDSA
+ippsECCPSignNR
+ippsECCPVerifyNR
+ippsECCPSignSM2
+ippsECCPVerifySM2
+ippsGFpGetSize
+ippsGFpInitArbitrary
+ippsGFpInitFixed
+ippsGFpInit
+ippsGFpMethod_p192r1
+ippsGFpMethod_p224r1
+ippsGFpMethod_p256r1
+ippsGFpMethod_p384r1
+ippsGFpMethod_p521r1
+ippsGFpMethod_p256sm2
+ippsGFpMethod_p256bn
+ippsGFpMethod_p256
+ippsGFpMethod_pArb
+ippsGFpxGetSize
+ippsGFpxInit
+ippsGFpxInitBinomial
+ippsGFpxMethod_binom2_epid2
+ippsGFpxMethod_binom3_epid2
+ippsGFpxMethod_binom2
+ippsGFpxMethod_binom3
+ippsGFpxMethod_binom
+ippsGFpxMethod_com
+ippsGFpScratchBufferSize
+ippsGFpElementGetSize
+ippsGFpElementInit
+ippsGFpSetElement
+ippsGFpSetElementRegular
+ippsGFpSetElementOctString
+ippsGFpSetElementRandom
+ippsGFpSetElementHash
+ippsGFpSetElementHash_rmf
+ippsGFpCpyElement
+ippsGFpGetElement
+ippsGFpGetElementOctString
+ippsGFpCmpElement
+ippsGFpIsZeroElement
+ippsGFpIsUnityElement
+ippsGFpConj
+ippsGFpNeg
+ippsGFpInv
+ippsGFpSqrt
+ippsGFpSqr
+ippsGFpAdd
+ippsGFpSub
+ippsGFpMul
+ippsGFpExp
+ippsGFpMultiExp
+ippsGFpAdd_PE
+ippsGFpSub_PE
+ippsGFpMul_PE
+ippsGFpECGetSize
+ippsGFpECInit
+ippsGFpECSet
+ippsGFpECSetSubgroup
+ippsGFpECInitStd128r1
+ippsGFpECInitStd128r2
+ippsGFpECInitStd192r1
+ippsGFpECInitStd224r1
+ippsGFpECInitStd256r1
+ippsGFpECInitStd384r1
+ippsGFpECInitStd521r1
+ippsGFpECInitStdSM2
+ippsGFpECInitStdBN256
+ippsGFpECBindGxyTblStd192r1
+ippsGFpECBindGxyTblStd224r1
+ippsGFpECBindGxyTblStd256r1
+ippsGFpECBindGxyTblStd384r1
+ippsGFpECBindGxyTblStd521r1
+ippsGFpECBindGxyTblStdSM2
+ippsGFpECGet
+ippsGFpECGetSubgroup
+ippsGFpECScratchBufferSize
+ippsGFpECVerify
+ippsGFpECPointGetSize
+ippsGFpECPointInit
+ippsGFpECSetPointAtInfinity
+ippsGFpECSetPoint
+ippsGFpECSetPointRegular
+ippsGFpECSetPointRandom
+ippsGFpECMakePoint
+ippsGFpECSetPointHash
+ippsGFpECSetPointHash_rmf
+ippsGFpECGetPoint
+ippsGFpECGetPointRegular
+ippsGFpECSetPointOctString
+ippsGFpECGetPointOctString
+ippsGFpECTstPoint
+ippsGFpECTstPointInSubgroup
+ippsGFpECCpyPoint
+ippsGFpECCmpPoint
+ippsGFpECNegPoint
+ippsGFpECAddPoint
+ippsGFpECMulPoint
+ippsGFpECPrivateKey
+ippsGFpECPublicKey
+ippsGFpECTstKeyPair
+ippsGFpECSharedSecretDH
+ippsGFpECSharedSecretDHC
+ippsGFpECSignDSA
+ippsGFpECVerifyDSA
+ippsGFpECSignNR
+ippsGFpECVerifyNR
+ippsGFpECSignSM2
+ippsGFpECVerifySM2
+ippsGFpECESGetSize_SM2
+ippsGFpECESInit_SM2
+ippsGFpECESSetKey_SM2
+ippsGFpECESStart_SM2
+ippsGFpECESEncrypt_SM2
+ippsGFpECESDecrypt_SM2
+ippsGFpECESFinal_SM2
+ippsGFpECESGetBuffersSize_SM2 \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/owncp.h b/ext/ipp/sources/ippcp/owncp.h
new file mode 100644
index 0000000..c5dec5e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/owncp.h
@@ -0,0 +1,711 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+*/
+
+#ifndef __OWNCP_H__
+#define __OWNCP_H__
+
+#ifndef __OWNDEFS_H__
+ #include "owndefs.h"
+#endif
+
+#ifndef IPPCP_H__
+
+#define ippcpGetLibVersion OWNAPI(ippcpGetLibVersion)
+#define ippsDESGetSize OWNAPI(ippsDESGetSize)
+#define ippsDESInit OWNAPI(ippsDESInit)
+#define ippsDESPack OWNAPI(ippsDESPack)
+#define ippsDESUnpack OWNAPI(ippsDESUnpack)
+#define ippsTDESEncryptECB OWNAPI(ippsTDESEncryptECB)
+#define ippsTDESDecryptECB OWNAPI(ippsTDESDecryptECB)
+#define ippsTDESEncryptCBC OWNAPI(ippsTDESEncryptCBC)
+#define ippsTDESDecryptCBC OWNAPI(ippsTDESDecryptCBC)
+#define ippsTDESEncryptCFB OWNAPI(ippsTDESEncryptCFB)
+#define ippsTDESDecryptCFB OWNAPI(ippsTDESDecryptCFB)
+#define ippsTDESEncryptOFB OWNAPI(ippsTDESEncryptOFB)
+#define ippsTDESDecryptOFB OWNAPI(ippsTDESDecryptOFB)
+#define ippsTDESEncryptCTR OWNAPI(ippsTDESEncryptCTR)
+#define ippsTDESDecryptCTR OWNAPI(ippsTDESDecryptCTR)
+#define ippsAESGetSize OWNAPI(ippsAESGetSize)
+#define ippsAESInit OWNAPI(ippsAESInit)
+#define ippsAESSetKey OWNAPI(ippsAESSetKey)
+#define ippsAESPack OWNAPI(ippsAESPack)
+#define ippsAESUnpack OWNAPI(ippsAESUnpack)
+#define ippsAESEncryptECB OWNAPI(ippsAESEncryptECB)
+#define ippsAESDecryptECB OWNAPI(ippsAESDecryptECB)
+#define ippsAESEncryptCBC OWNAPI(ippsAESEncryptCBC)
+#define ippsAESEncryptCBC_CS1 OWNAPI(ippsAESEncryptCBC_CS1)
+#define ippsAESEncryptCBC_CS2 OWNAPI(ippsAESEncryptCBC_CS2)
+#define ippsAESEncryptCBC_CS3 OWNAPI(ippsAESEncryptCBC_CS3)
+#define ippsAESDecryptCBC OWNAPI(ippsAESDecryptCBC)
+#define ippsAESDecryptCBC_CS1 OWNAPI(ippsAESDecryptCBC_CS1)
+#define ippsAESDecryptCBC_CS2 OWNAPI(ippsAESDecryptCBC_CS2)
+#define ippsAESDecryptCBC_CS3 OWNAPI(ippsAESDecryptCBC_CS3)
+#define ippsAESEncryptCFB OWNAPI(ippsAESEncryptCFB)
+#define ippsAESDecryptCFB OWNAPI(ippsAESDecryptCFB)
+#define ippsAESEncryptOFB OWNAPI(ippsAESEncryptOFB)
+#define ippsAESDecryptOFB OWNAPI(ippsAESDecryptOFB)
+#define ippsAESEncryptCTR OWNAPI(ippsAESEncryptCTR)
+#define ippsAESDecryptCTR OWNAPI(ippsAESDecryptCTR)
+#define ippsAESEncryptXTS_Direct OWNAPI(ippsAESEncryptXTS_Direct)
+#define ippsAESDecryptXTS_Direct OWNAPI(ippsAESDecryptXTS_Direct)
+#define ippsSMS4GetSize OWNAPI(ippsSMS4GetSize)
+#define ippsSMS4Init OWNAPI(ippsSMS4Init)
+#define ippsSMS4SetKey OWNAPI(ippsSMS4SetKey)
+#define ippsSMS4EncryptECB OWNAPI(ippsSMS4EncryptECB)
+#define ippsSMS4DecryptECB OWNAPI(ippsSMS4DecryptECB)
+#define ippsSMS4EncryptCBC OWNAPI(ippsSMS4EncryptCBC)
+#define ippsSMS4EncryptCBC_CS1 OWNAPI(ippsSMS4EncryptCBC_CS1)
+#define ippsSMS4EncryptCBC_CS2 OWNAPI(ippsSMS4EncryptCBC_CS2)
+#define ippsSMS4EncryptCBC_CS3 OWNAPI(ippsSMS4EncryptCBC_CS3)
+#define ippsSMS4DecryptCBC OWNAPI(ippsSMS4DecryptCBC)
+#define ippsSMS4DecryptCBC_CS1 OWNAPI(ippsSMS4DecryptCBC_CS1)
+#define ippsSMS4DecryptCBC_CS2 OWNAPI(ippsSMS4DecryptCBC_CS2)
+#define ippsSMS4DecryptCBC_CS3 OWNAPI(ippsSMS4DecryptCBC_CS3)
+#define ippsSMS4EncryptCFB OWNAPI(ippsSMS4EncryptCFB)
+#define ippsSMS4DecryptCFB OWNAPI(ippsSMS4DecryptCFB)
+#define ippsSMS4EncryptOFB OWNAPI(ippsSMS4EncryptOFB)
+#define ippsSMS4DecryptOFB OWNAPI(ippsSMS4DecryptOFB)
+#define ippsSMS4EncryptCTR OWNAPI(ippsSMS4EncryptCTR)
+#define ippsSMS4DecryptCTR OWNAPI(ippsSMS4DecryptCTR)
+#define ippsSMS4_CCMGetSize OWNAPI(ippsSMS4_CCMGetSize)
+#define ippsSMS4_CCMInit OWNAPI(ippsSMS4_CCMInit)
+#define ippsSMS4_CCMMessageLen OWNAPI(ippsSMS4_CCMMessageLen)
+#define ippsSMS4_CCMTagLen OWNAPI(ippsSMS4_CCMTagLen)
+#define ippsSMS4_CCMStart OWNAPI(ippsSMS4_CCMStart)
+#define ippsSMS4_CCMEncrypt OWNAPI(ippsSMS4_CCMEncrypt)
+#define ippsSMS4_CCMDecrypt OWNAPI(ippsSMS4_CCMDecrypt)
+#define ippsSMS4_CCMGetTag OWNAPI(ippsSMS4_CCMGetTag)
+#define ippsAES_CCMGetSize OWNAPI(ippsAES_CCMGetSize)
+#define ippsAES_CCMInit OWNAPI(ippsAES_CCMInit)
+#define ippsAES_CCMMessageLen OWNAPI(ippsAES_CCMMessageLen)
+#define ippsAES_CCMTagLen OWNAPI(ippsAES_CCMTagLen)
+#define ippsAES_CCMStart OWNAPI(ippsAES_CCMStart)
+#define ippsAES_CCMEncrypt OWNAPI(ippsAES_CCMEncrypt)
+#define ippsAES_CCMDecrypt OWNAPI(ippsAES_CCMDecrypt)
+#define ippsAES_CCMGetTag OWNAPI(ippsAES_CCMGetTag)
+#define ippsAES_GCMGetSize OWNAPI(ippsAES_GCMGetSize)
+#define ippsAES_GCMInit OWNAPI(ippsAES_GCMInit)
+#define ippsAES_GCMReset OWNAPI(ippsAES_GCMReset)
+#define ippsAES_GCMProcessIV OWNAPI(ippsAES_GCMProcessIV)
+#define ippsAES_GCMProcessAAD OWNAPI(ippsAES_GCMProcessAAD)
+#define ippsAES_GCMStart OWNAPI(ippsAES_GCMStart)
+#define ippsAES_GCMEncrypt OWNAPI(ippsAES_GCMEncrypt)
+#define ippsAES_GCMDecrypt OWNAPI(ippsAES_GCMDecrypt)
+#define ippsAES_GCMGetTag OWNAPI(ippsAES_GCMGetTag)
+#define ippsAES_XTSGetSize OWNAPI(ippsAES_XTSGetSize)
+#define ippsAES_XTSInit OWNAPI(ippsAES_XTSInit)
+#define ippsAES_XTSEncrypt OWNAPI(ippsAES_XTSEncrypt)
+#define ippsAES_XTSDecrypt OWNAPI(ippsAES_XTSDecrypt)
+#define ippsAES_S2V_CMAC OWNAPI(ippsAES_S2V_CMAC)
+#define ippsAES_SIVEncrypt OWNAPI(ippsAES_SIVEncrypt)
+#define ippsAES_SIVDecrypt OWNAPI(ippsAES_SIVDecrypt)
+#define ippsAES_CMACGetSize OWNAPI(ippsAES_CMACGetSize)
+#define ippsAES_CMACInit OWNAPI(ippsAES_CMACInit)
+#define ippsAES_CMACUpdate OWNAPI(ippsAES_CMACUpdate)
+#define ippsAES_CMACFinal OWNAPI(ippsAES_CMACFinal)
+#define ippsAES_CMACGetTag OWNAPI(ippsAES_CMACGetTag)
+#define ippsARCFourCheckKey OWNAPI(ippsARCFourCheckKey)
+#define ippsARCFourGetSize OWNAPI(ippsARCFourGetSize)
+#define ippsARCFourInit OWNAPI(ippsARCFourInit)
+#define ippsARCFourReset OWNAPI(ippsARCFourReset)
+#define ippsARCFourPack OWNAPI(ippsARCFourPack)
+#define ippsARCFourUnpack OWNAPI(ippsARCFourUnpack)
+#define ippsARCFourEncrypt OWNAPI(ippsARCFourEncrypt)
+#define ippsARCFourDecrypt OWNAPI(ippsARCFourDecrypt)
+#define ippsSHA1GetSize OWNAPI(ippsSHA1GetSize)
+#define ippsSHA1Init OWNAPI(ippsSHA1Init)
+#define ippsSHA1Duplicate OWNAPI(ippsSHA1Duplicate)
+#define ippsSHA1Pack OWNAPI(ippsSHA1Pack)
+#define ippsSHA1Unpack OWNAPI(ippsSHA1Unpack)
+#define ippsSHA1Update OWNAPI(ippsSHA1Update)
+#define ippsSHA1GetTag OWNAPI(ippsSHA1GetTag)
+#define ippsSHA1Final OWNAPI(ippsSHA1Final)
+#define ippsSHA1MessageDigest OWNAPI(ippsSHA1MessageDigest)
+#define ippsSHA224GetSize OWNAPI(ippsSHA224GetSize)
+#define ippsSHA224Init OWNAPI(ippsSHA224Init)
+#define ippsSHA224Duplicate OWNAPI(ippsSHA224Duplicate)
+#define ippsSHA224Pack OWNAPI(ippsSHA224Pack)
+#define ippsSHA224Unpack OWNAPI(ippsSHA224Unpack)
+#define ippsSHA224Update OWNAPI(ippsSHA224Update)
+#define ippsSHA224GetTag OWNAPI(ippsSHA224GetTag)
+#define ippsSHA224Final OWNAPI(ippsSHA224Final)
+#define ippsSHA224MessageDigest OWNAPI(ippsSHA224MessageDigest)
+#define ippsSHA256GetSize OWNAPI(ippsSHA256GetSize)
+#define ippsSHA256Init OWNAPI(ippsSHA256Init)
+#define ippsSHA256Duplicate OWNAPI(ippsSHA256Duplicate)
+#define ippsSHA256Pack OWNAPI(ippsSHA256Pack)
+#define ippsSHA256Unpack OWNAPI(ippsSHA256Unpack)
+#define ippsSHA256Update OWNAPI(ippsSHA256Update)
+#define ippsSHA256GetTag OWNAPI(ippsSHA256GetTag)
+#define ippsSHA256Final OWNAPI(ippsSHA256Final)
+#define ippsSHA256MessageDigest OWNAPI(ippsSHA256MessageDigest)
+#define ippsSHA384GetSize OWNAPI(ippsSHA384GetSize)
+#define ippsSHA384Init OWNAPI(ippsSHA384Init)
+#define ippsSHA384Duplicate OWNAPI(ippsSHA384Duplicate)
+#define ippsSHA384Pack OWNAPI(ippsSHA384Pack)
+#define ippsSHA384Unpack OWNAPI(ippsSHA384Unpack)
+#define ippsSHA384Update OWNAPI(ippsSHA384Update)
+#define ippsSHA384GetTag OWNAPI(ippsSHA384GetTag)
+#define ippsSHA384Final OWNAPI(ippsSHA384Final)
+#define ippsSHA384MessageDigest OWNAPI(ippsSHA384MessageDigest)
+#define ippsSHA512GetSize OWNAPI(ippsSHA512GetSize)
+#define ippsSHA512Init OWNAPI(ippsSHA512Init)
+#define ippsSHA512Duplicate OWNAPI(ippsSHA512Duplicate)
+#define ippsSHA512Pack OWNAPI(ippsSHA512Pack)
+#define ippsSHA512Unpack OWNAPI(ippsSHA512Unpack)
+#define ippsSHA512Update OWNAPI(ippsSHA512Update)
+#define ippsSHA512GetTag OWNAPI(ippsSHA512GetTag)
+#define ippsSHA512Final OWNAPI(ippsSHA512Final)
+#define ippsSHA512MessageDigest OWNAPI(ippsSHA512MessageDigest)
+#define ippsMD5GetSize OWNAPI(ippsMD5GetSize)
+#define ippsMD5Init OWNAPI(ippsMD5Init)
+#define ippsMD5Duplicate OWNAPI(ippsMD5Duplicate)
+#define ippsMD5Pack OWNAPI(ippsMD5Pack)
+#define ippsMD5Unpack OWNAPI(ippsMD5Unpack)
+#define ippsMD5Update OWNAPI(ippsMD5Update)
+#define ippsMD5GetTag OWNAPI(ippsMD5GetTag)
+#define ippsMD5Final OWNAPI(ippsMD5Final)
+#define ippsMD5MessageDigest OWNAPI(ippsMD5MessageDigest)
+#define ippsSM3GetSize OWNAPI(ippsSM3GetSize)
+#define ippsSM3Init OWNAPI(ippsSM3Init)
+#define ippsSM3Duplicate OWNAPI(ippsSM3Duplicate)
+#define ippsSM3Pack OWNAPI(ippsSM3Pack)
+#define ippsSM3Unpack OWNAPI(ippsSM3Unpack)
+#define ippsSM3Update OWNAPI(ippsSM3Update)
+#define ippsSM3GetTag OWNAPI(ippsSM3GetTag)
+#define ippsSM3Final OWNAPI(ippsSM3Final)
+#define ippsSM3MessageDigest OWNAPI(ippsSM3MessageDigest)
+#define ippsHashGetSize OWNAPI(ippsHashGetSize)
+#define ippsHashInit OWNAPI(ippsHashInit)
+#define ippsHashPack OWNAPI(ippsHashPack)
+#define ippsHashUnpack OWNAPI(ippsHashUnpack)
+#define ippsHashDuplicate OWNAPI(ippsHashDuplicate)
+#define ippsHashUpdate OWNAPI(ippsHashUpdate)
+#define ippsHashGetTag OWNAPI(ippsHashGetTag)
+#define ippsHashFinal OWNAPI(ippsHashFinal)
+#define ippsHashMessage OWNAPI(ippsHashMessage)
+#define ippsHashMethod_MD5 OWNAPI(ippsHashMethod_MD5)
+#define ippsHashMethod_SM3 OWNAPI(ippsHashMethod_SM3)
+#define ippsHashMethod_SHA1 OWNAPI(ippsHashMethod_SHA1)
+#define ippsHashMethod_SHA1_NI OWNAPI(ippsHashMethod_SHA1_NI)
+#define ippsHashMethod_SHA1_TT OWNAPI(ippsHashMethod_SHA1_TT)
+#define ippsHashMethod_SHA256 OWNAPI(ippsHashMethod_SHA256)
+#define ippsHashMethod_SHA256_NI OWNAPI(ippsHashMethod_SHA256_NI)
+#define ippsHashMethod_SHA256_TT OWNAPI(ippsHashMethod_SHA256_TT)
+#define ippsHashMethod_SHA224 OWNAPI(ippsHashMethod_SHA224)
+#define ippsHashMethod_SHA224_NI OWNAPI(ippsHashMethod_SHA224_NI)
+#define ippsHashMethod_SHA224_TT OWNAPI(ippsHashMethod_SHA224_TT)
+#define ippsHashMethod_SHA512 OWNAPI(ippsHashMethod_SHA512)
+#define ippsHashMethod_SHA384 OWNAPI(ippsHashMethod_SHA384)
+#define ippsHashMethod_SHA512_256 OWNAPI(ippsHashMethod_SHA512_256)
+#define ippsHashMethod_SHA512_224 OWNAPI(ippsHashMethod_SHA512_224)
+#define ippsHashGetSize_rmf OWNAPI(ippsHashGetSize_rmf)
+#define ippsHashInit_rmf OWNAPI(ippsHashInit_rmf)
+#define ippsHashPack_rmf OWNAPI(ippsHashPack_rmf)
+#define ippsHashUnpack_rmf OWNAPI(ippsHashUnpack_rmf)
+#define ippsHashDuplicate_rmf OWNAPI(ippsHashDuplicate_rmf)
+#define ippsHashUpdate_rmf OWNAPI(ippsHashUpdate_rmf)
+#define ippsHashGetTag_rmf OWNAPI(ippsHashGetTag_rmf)
+#define ippsHashFinal_rmf OWNAPI(ippsHashFinal_rmf)
+#define ippsHashMessage_rmf OWNAPI(ippsHashMessage_rmf)
+#define ippsMGF OWNAPI(ippsMGF)
+#define ippsMGF1_rmf OWNAPI(ippsMGF1_rmf)
+#define ippsMGF2_rmf OWNAPI(ippsMGF2_rmf)
+#define ippsHMAC_GetSize OWNAPI(ippsHMAC_GetSize)
+#define ippsHMAC_Init OWNAPI(ippsHMAC_Init)
+#define ippsHMAC_Pack OWNAPI(ippsHMAC_Pack)
+#define ippsHMAC_Unpack OWNAPI(ippsHMAC_Unpack)
+#define ippsHMAC_Duplicate OWNAPI(ippsHMAC_Duplicate)
+#define ippsHMAC_Update OWNAPI(ippsHMAC_Update)
+#define ippsHMAC_Final OWNAPI(ippsHMAC_Final)
+#define ippsHMAC_GetTag OWNAPI(ippsHMAC_GetTag)
+#define ippsHMAC_Message OWNAPI(ippsHMAC_Message)
+#define ippsHMACGetSize_rmf OWNAPI(ippsHMACGetSize_rmf)
+#define ippsHMACInit_rmf OWNAPI(ippsHMACInit_rmf)
+#define ippsHMACPack_rmf OWNAPI(ippsHMACPack_rmf)
+#define ippsHMACUnpack_rmf OWNAPI(ippsHMACUnpack_rmf)
+#define ippsHMACDuplicate_rmf OWNAPI(ippsHMACDuplicate_rmf)
+#define ippsHMACUpdate_rmf OWNAPI(ippsHMACUpdate_rmf)
+#define ippsHMACFinal_rmf OWNAPI(ippsHMACFinal_rmf)
+#define ippsHMACGetTag_rmf OWNAPI(ippsHMACGetTag_rmf)
+#define ippsHMACMessage_rmf OWNAPI(ippsHMACMessage_rmf)
+#define ippsBigNumGetSize OWNAPI(ippsBigNumGetSize)
+#define ippsBigNumInit OWNAPI(ippsBigNumInit)
+#define ippsCmpZero_BN OWNAPI(ippsCmpZero_BN)
+#define ippsCmp_BN OWNAPI(ippsCmp_BN)
+#define ippsGetSize_BN OWNAPI(ippsGetSize_BN)
+#define ippsSet_BN OWNAPI(ippsSet_BN)
+#define ippsGet_BN OWNAPI(ippsGet_BN)
+#define ippsRef_BN OWNAPI(ippsRef_BN)
+#define ippsExtGet_BN OWNAPI(ippsExtGet_BN)
+#define ippsAdd_BN OWNAPI(ippsAdd_BN)
+#define ippsSub_BN OWNAPI(ippsSub_BN)
+#define ippsMul_BN OWNAPI(ippsMul_BN)
+#define ippsMAC_BN_I OWNAPI(ippsMAC_BN_I)
+#define ippsDiv_BN OWNAPI(ippsDiv_BN)
+#define ippsMod_BN OWNAPI(ippsMod_BN)
+#define ippsGcd_BN OWNAPI(ippsGcd_BN)
+#define ippsModInv_BN OWNAPI(ippsModInv_BN)
+#define ippsSetOctString_BN OWNAPI(ippsSetOctString_BN)
+#define ippsGetOctString_BN OWNAPI(ippsGetOctString_BN)
+#define ippsMontGetSize OWNAPI(ippsMontGetSize)
+#define ippsMontInit OWNAPI(ippsMontInit)
+#define ippsMontSet OWNAPI(ippsMontSet)
+#define ippsMontGet OWNAPI(ippsMontGet)
+#define ippsMontForm OWNAPI(ippsMontForm)
+#define ippsMontMul OWNAPI(ippsMontMul)
+#define ippsMontExp OWNAPI(ippsMontExp)
+#define ippsPRNGGetSize OWNAPI(ippsPRNGGetSize)
+#define ippsPRNGInit OWNAPI(ippsPRNGInit)
+#define ippsPRNGSetModulus OWNAPI(ippsPRNGSetModulus)
+#define ippsPRNGSetH0 OWNAPI(ippsPRNGSetH0)
+#define ippsPRNGSetAugment OWNAPI(ippsPRNGSetAugment)
+#define ippsPRNGSetSeed OWNAPI(ippsPRNGSetSeed)
+#define ippsPRNGGetSeed OWNAPI(ippsPRNGGetSeed)
+#define ippsPRNGen OWNAPI(ippsPRNGen)
+#define ippsPRNGen_BN OWNAPI(ippsPRNGen_BN)
+#define ippsPRNGenRDRAND OWNAPI(ippsPRNGenRDRAND)
+#define ippsPRNGenRDRAND_BN OWNAPI(ippsPRNGenRDRAND_BN)
+#define ippsTRNGenRDSEED OWNAPI(ippsTRNGenRDSEED)
+#define ippsTRNGenRDSEED_BN OWNAPI(ippsTRNGenRDSEED_BN)
+#define ippsPrimeGetSize OWNAPI(ippsPrimeGetSize)
+#define ippsPrimeInit OWNAPI(ippsPrimeInit)
+#define ippsPrimeGen OWNAPI(ippsPrimeGen)
+#define ippsPrimeTest OWNAPI(ippsPrimeTest)
+#define ippsPrimeGen_BN OWNAPI(ippsPrimeGen_BN)
+#define ippsPrimeTest_BN OWNAPI(ippsPrimeTest_BN)
+#define ippsPrimeGet OWNAPI(ippsPrimeGet)
+#define ippsPrimeGet_BN OWNAPI(ippsPrimeGet_BN)
+#define ippsPrimeSet OWNAPI(ippsPrimeSet)
+#define ippsPrimeSet_BN OWNAPI(ippsPrimeSet_BN)
+#define ippsRSA_GetSizePublicKey OWNAPI(ippsRSA_GetSizePublicKey)
+#define ippsRSA_InitPublicKey OWNAPI(ippsRSA_InitPublicKey)
+#define ippsRSA_SetPublicKey OWNAPI(ippsRSA_SetPublicKey)
+#define ippsRSA_GetPublicKey OWNAPI(ippsRSA_GetPublicKey)
+#define ippsRSA_GetSizePrivateKeyType1 OWNAPI(ippsRSA_GetSizePrivateKeyType1)
+#define ippsRSA_InitPrivateKeyType1 OWNAPI(ippsRSA_InitPrivateKeyType1)
+#define ippsRSA_SetPrivateKeyType1 OWNAPI(ippsRSA_SetPrivateKeyType1)
+#define ippsRSA_GetPrivateKeyType1 OWNAPI(ippsRSA_GetPrivateKeyType1)
+#define ippsRSA_GetSizePrivateKeyType2 OWNAPI(ippsRSA_GetSizePrivateKeyType2)
+#define ippsRSA_InitPrivateKeyType2 OWNAPI(ippsRSA_InitPrivateKeyType2)
+#define ippsRSA_SetPrivateKeyType2 OWNAPI(ippsRSA_SetPrivateKeyType2)
+#define ippsRSA_GetPrivateKeyType2 OWNAPI(ippsRSA_GetPrivateKeyType2)
+#define ippsRSA_GetBufferSizePublicKey OWNAPI(ippsRSA_GetBufferSizePublicKey)
+#define ippsRSA_GetBufferSizePrivateKey OWNAPI(ippsRSA_GetBufferSizePrivateKey)
+#define ippsRSA_Encrypt OWNAPI(ippsRSA_Encrypt)
+#define ippsRSA_Decrypt OWNAPI(ippsRSA_Decrypt)
+#define ippsRSA_GenerateKeys OWNAPI(ippsRSA_GenerateKeys)
+#define ippsRSA_ValidateKeys OWNAPI(ippsRSA_ValidateKeys)
+#define ippsRSAEncrypt_OAEP OWNAPI(ippsRSAEncrypt_OAEP)
+#define ippsRSADecrypt_OAEP OWNAPI(ippsRSADecrypt_OAEP)
+#define ippsRSAEncrypt_OAEP_rmf OWNAPI(ippsRSAEncrypt_OAEP_rmf)
+#define ippsRSADecrypt_OAEP_rmf OWNAPI(ippsRSADecrypt_OAEP_rmf)
+#define ippsRSAEncrypt_PKCSv15 OWNAPI(ippsRSAEncrypt_PKCSv15)
+#define ippsRSADecrypt_PKCSv15 OWNAPI(ippsRSADecrypt_PKCSv15)
+#define ippsRSASign_PSS OWNAPI(ippsRSASign_PSS)
+#define ippsRSAVerify_PSS OWNAPI(ippsRSAVerify_PSS)
+#define ippsRSASign_PSS_rmf OWNAPI(ippsRSASign_PSS_rmf)
+#define ippsRSAVerify_PSS_rmf OWNAPI(ippsRSAVerify_PSS_rmf)
+#define ippsRSASign_PKCS1v15 OWNAPI(ippsRSASign_PKCS1v15)
+#define ippsRSAVerify_PKCS1v15 OWNAPI(ippsRSAVerify_PKCS1v15)
+#define ippsRSASign_PKCS1v15_rmf OWNAPI(ippsRSASign_PKCS1v15_rmf)
+#define ippsRSAVerify_PKCS1v15_rmf OWNAPI(ippsRSAVerify_PKCS1v15_rmf)
+#define ippsDLGetResultString OWNAPI(ippsDLGetResultString)
+#define ippsDLPGetSize OWNAPI(ippsDLPGetSize)
+#define ippsDLPInit OWNAPI(ippsDLPInit)
+#define ippsDLPPack OWNAPI(ippsDLPPack)
+#define ippsDLPUnpack OWNAPI(ippsDLPUnpack)
+#define ippsDLPSet OWNAPI(ippsDLPSet)
+#define ippsDLPGet OWNAPI(ippsDLPGet)
+#define ippsDLPSetDP OWNAPI(ippsDLPSetDP)
+#define ippsDLPGetDP OWNAPI(ippsDLPGetDP)
+#define ippsDLPGenKeyPair OWNAPI(ippsDLPGenKeyPair)
+#define ippsDLPPublicKey OWNAPI(ippsDLPPublicKey)
+#define ippsDLPValidateKeyPair OWNAPI(ippsDLPValidateKeyPair)
+#define ippsDLPSetKeyPair OWNAPI(ippsDLPSetKeyPair)
+#define ippsDLPSignDSA OWNAPI(ippsDLPSignDSA)
+#define ippsDLPVerifyDSA OWNAPI(ippsDLPVerifyDSA)
+#define ippsDLPSharedSecretDH OWNAPI(ippsDLPSharedSecretDH)
+#define ippsDLPGenerateDSA OWNAPI(ippsDLPGenerateDSA)
+#define ippsDLPValidateDSA OWNAPI(ippsDLPValidateDSA)
+#define ippsDLPGenerateDH OWNAPI(ippsDLPGenerateDH)
+#define ippsDLPValidateDH OWNAPI(ippsDLPValidateDH)
+#define ippsECCGetResultString OWNAPI(ippsECCGetResultString)
+#define ippsECCPGetSize OWNAPI(ippsECCPGetSize)
+#define ippsECCPGetSizeStd128r1 OWNAPI(ippsECCPGetSizeStd128r1)
+#define ippsECCPGetSizeStd128r2 OWNAPI(ippsECCPGetSizeStd128r2)
+#define ippsECCPGetSizeStd192r1 OWNAPI(ippsECCPGetSizeStd192r1)
+#define ippsECCPGetSizeStd224r1 OWNAPI(ippsECCPGetSizeStd224r1)
+#define ippsECCPGetSizeStd256r1 OWNAPI(ippsECCPGetSizeStd256r1)
+#define ippsECCPGetSizeStd384r1 OWNAPI(ippsECCPGetSizeStd384r1)
+#define ippsECCPGetSizeStd521r1 OWNAPI(ippsECCPGetSizeStd521r1)
+#define ippsECCPGetSizeStdSM2 OWNAPI(ippsECCPGetSizeStdSM2)
+#define ippsECCPInit OWNAPI(ippsECCPInit)
+#define ippsECCPInitStd128r1 OWNAPI(ippsECCPInitStd128r1)
+#define ippsECCPInitStd128r2 OWNAPI(ippsECCPInitStd128r2)
+#define ippsECCPInitStd192r1 OWNAPI(ippsECCPInitStd192r1)
+#define ippsECCPInitStd224r1 OWNAPI(ippsECCPInitStd224r1)
+#define ippsECCPInitStd256r1 OWNAPI(ippsECCPInitStd256r1)
+#define ippsECCPInitStd384r1 OWNAPI(ippsECCPInitStd384r1)
+#define ippsECCPInitStd521r1 OWNAPI(ippsECCPInitStd521r1)
+#define ippsECCPInitStdSM2 OWNAPI(ippsECCPInitStdSM2)
+#define ippsECCPSet OWNAPI(ippsECCPSet)
+#define ippsECCPSetStd OWNAPI(ippsECCPSetStd)
+#define ippsECCPSetStd128r1 OWNAPI(ippsECCPSetStd128r1)
+#define ippsECCPSetStd128r2 OWNAPI(ippsECCPSetStd128r2)
+#define ippsECCPSetStd192r1 OWNAPI(ippsECCPSetStd192r1)
+#define ippsECCPSetStd224r1 OWNAPI(ippsECCPSetStd224r1)
+#define ippsECCPSetStd256r1 OWNAPI(ippsECCPSetStd256r1)
+#define ippsECCPSetStd384r1 OWNAPI(ippsECCPSetStd384r1)
+#define ippsECCPSetStd521r1 OWNAPI(ippsECCPSetStd521r1)
+#define ippsECCPSetStdSM2 OWNAPI(ippsECCPSetStdSM2)
+#define ippsECCPBindGxyTblStd192r1 OWNAPI(ippsECCPBindGxyTblStd192r1)
+#define ippsECCPBindGxyTblStd224r1 OWNAPI(ippsECCPBindGxyTblStd224r1)
+#define ippsECCPBindGxyTblStd256r1 OWNAPI(ippsECCPBindGxyTblStd256r1)
+#define ippsECCPBindGxyTblStd384r1 OWNAPI(ippsECCPBindGxyTblStd384r1)
+#define ippsECCPBindGxyTblStd521r1 OWNAPI(ippsECCPBindGxyTblStd521r1)
+#define ippsECCPBindGxyTblStdSM2 OWNAPI(ippsECCPBindGxyTblStdSM2)
+#define ippsECCPGet OWNAPI(ippsECCPGet)
+#define ippsECCPGetOrderBitSize OWNAPI(ippsECCPGetOrderBitSize)
+#define ippsECCPValidate OWNAPI(ippsECCPValidate)
+#define ippsECCPPointGetSize OWNAPI(ippsECCPPointGetSize)
+#define ippsECCPPointInit OWNAPI(ippsECCPPointInit)
+#define ippsECCPSetPoint OWNAPI(ippsECCPSetPoint)
+#define ippsECCPSetPointAtInfinity OWNAPI(ippsECCPSetPointAtInfinity)
+#define ippsECCPGetPoint OWNAPI(ippsECCPGetPoint)
+#define ippsECCPCheckPoint OWNAPI(ippsECCPCheckPoint)
+#define ippsECCPComparePoint OWNAPI(ippsECCPComparePoint)
+#define ippsECCPNegativePoint OWNAPI(ippsECCPNegativePoint)
+#define ippsECCPAddPoint OWNAPI(ippsECCPAddPoint)
+#define ippsECCPMulPointScalar OWNAPI(ippsECCPMulPointScalar)
+#define ippsECCPGenKeyPair OWNAPI(ippsECCPGenKeyPair)
+#define ippsECCPPublicKey OWNAPI(ippsECCPPublicKey)
+#define ippsECCPValidateKeyPair OWNAPI(ippsECCPValidateKeyPair)
+#define ippsECCPSetKeyPair OWNAPI(ippsECCPSetKeyPair)
+#define ippsECCPSharedSecretDH OWNAPI(ippsECCPSharedSecretDH)
+#define ippsECCPSharedSecretDHC OWNAPI(ippsECCPSharedSecretDHC)
+#define ippsECCPSignDSA OWNAPI(ippsECCPSignDSA)
+#define ippsECCPVerifyDSA OWNAPI(ippsECCPVerifyDSA)
+#define ippsECCPSignNR OWNAPI(ippsECCPSignNR)
+#define ippsECCPVerifyNR OWNAPI(ippsECCPVerifyNR)
+#define ippsECCPSignSM2 OWNAPI(ippsECCPSignSM2)
+#define ippsECCPVerifySM2 OWNAPI(ippsECCPVerifySM2)
+#define ippsGFpGetSize OWNAPI(ippsGFpGetSize)
+#define ippsGFpInitArbitrary OWNAPI(ippsGFpInitArbitrary)
+#define ippsGFpInitFixed OWNAPI(ippsGFpInitFixed)
+#define ippsGFpInit OWNAPI(ippsGFpInit)
+#define ippsGFpMethod_p192r1 OWNAPI(ippsGFpMethod_p192r1)
+#define ippsGFpMethod_p224r1 OWNAPI(ippsGFpMethod_p224r1)
+#define ippsGFpMethod_p256r1 OWNAPI(ippsGFpMethod_p256r1)
+#define ippsGFpMethod_p384r1 OWNAPI(ippsGFpMethod_p384r1)
+#define ippsGFpMethod_p521r1 OWNAPI(ippsGFpMethod_p521r1)
+#define ippsGFpMethod_p256sm2 OWNAPI(ippsGFpMethod_p256sm2)
+#define ippsGFpMethod_p256bn OWNAPI(ippsGFpMethod_p256bn)
+#define ippsGFpMethod_p256 OWNAPI(ippsGFpMethod_p256)
+#define ippsGFpMethod_pArb OWNAPI(ippsGFpMethod_pArb)
+#define ippsGFpxGetSize OWNAPI(ippsGFpxGetSize)
+#define ippsGFpxInit OWNAPI(ippsGFpxInit)
+#define ippsGFpxInitBinomial OWNAPI(ippsGFpxInitBinomial)
+#define ippsGFpxMethod_binom2_epid2 OWNAPI(ippsGFpxMethod_binom2_epid2)
+#define ippsGFpxMethod_binom3_epid2 OWNAPI(ippsGFpxMethod_binom3_epid2)
+#define ippsGFpxMethod_binom2 OWNAPI(ippsGFpxMethod_binom2)
+#define ippsGFpxMethod_binom3 OWNAPI(ippsGFpxMethod_binom3)
+#define ippsGFpxMethod_binom OWNAPI(ippsGFpxMethod_binom)
+#define ippsGFpxMethod_com OWNAPI(ippsGFpxMethod_com)
+#define ippsGFpScratchBufferSize OWNAPI(ippsGFpScratchBufferSize)
+#define ippsGFpElementGetSize OWNAPI(ippsGFpElementGetSize)
+#define ippsGFpElementInit OWNAPI(ippsGFpElementInit)
+#define ippsGFpSetElement OWNAPI(ippsGFpSetElement)
+#define ippsGFpSetElementRegular OWNAPI(ippsGFpSetElementRegular)
+#define ippsGFpSetElementOctString OWNAPI(ippsGFpSetElementOctString)
+#define ippsGFpSetElementRandom OWNAPI(ippsGFpSetElementRandom)
+#define ippsGFpSetElementHash OWNAPI(ippsGFpSetElementHash)
+#define ippsGFpSetElementHash_rmf OWNAPI(ippsGFpSetElementHash_rmf)
+#define ippsGFpCpyElement OWNAPI(ippsGFpCpyElement)
+#define ippsGFpGetElement OWNAPI(ippsGFpGetElement)
+#define ippsGFpGetElementOctString OWNAPI(ippsGFpGetElementOctString)
+#define ippsGFpCmpElement OWNAPI(ippsGFpCmpElement)
+#define ippsGFpIsZeroElement OWNAPI(ippsGFpIsZeroElement)
+#define ippsGFpIsUnityElement OWNAPI(ippsGFpIsUnityElement)
+#define ippsGFpConj OWNAPI(ippsGFpConj)
+#define ippsGFpNeg OWNAPI(ippsGFpNeg)
+#define ippsGFpInv OWNAPI(ippsGFpInv)
+#define ippsGFpSqrt OWNAPI(ippsGFpSqrt)
+#define ippsGFpSqr OWNAPI(ippsGFpSqr)
+#define ippsGFpAdd OWNAPI(ippsGFpAdd)
+#define ippsGFpSub OWNAPI(ippsGFpSub)
+#define ippsGFpMul OWNAPI(ippsGFpMul)
+#define ippsGFpExp OWNAPI(ippsGFpExp)
+#define ippsGFpMultiExp OWNAPI(ippsGFpMultiExp)
+#define ippsGFpAdd_PE OWNAPI(ippsGFpAdd_PE)
+#define ippsGFpSub_PE OWNAPI(ippsGFpSub_PE)
+#define ippsGFpMul_PE OWNAPI(ippsGFpMul_PE)
+#define ippsGFpECGetSize OWNAPI(ippsGFpECGetSize)
+#define ippsGFpECInit OWNAPI(ippsGFpECInit)
+#define ippsGFpECSet OWNAPI(ippsGFpECSet)
+#define ippsGFpECSetSubgroup OWNAPI(ippsGFpECSetSubgroup)
+#define ippsGFpECInitStd128r1 OWNAPI(ippsGFpECInitStd128r1)
+#define ippsGFpECInitStd128r2 OWNAPI(ippsGFpECInitStd128r2)
+#define ippsGFpECInitStd192r1 OWNAPI(ippsGFpECInitStd192r1)
+#define ippsGFpECInitStd224r1 OWNAPI(ippsGFpECInitStd224r1)
+#define ippsGFpECInitStd256r1 OWNAPI(ippsGFpECInitStd256r1)
+#define ippsGFpECInitStd384r1 OWNAPI(ippsGFpECInitStd384r1)
+#define ippsGFpECInitStd521r1 OWNAPI(ippsGFpECInitStd521r1)
+#define ippsGFpECInitStdSM2 OWNAPI(ippsGFpECInitStdSM2)
+#define ippsGFpECInitStdBN256 OWNAPI(ippsGFpECInitStdBN256)
+#define ippsGFpECBindGxyTblStd192r1 OWNAPI(ippsGFpECBindGxyTblStd192r1)
+#define ippsGFpECBindGxyTblStd224r1 OWNAPI(ippsGFpECBindGxyTblStd224r1)
+#define ippsGFpECBindGxyTblStd256r1 OWNAPI(ippsGFpECBindGxyTblStd256r1)
+#define ippsGFpECBindGxyTblStd384r1 OWNAPI(ippsGFpECBindGxyTblStd384r1)
+#define ippsGFpECBindGxyTblStd521r1 OWNAPI(ippsGFpECBindGxyTblStd521r1)
+#define ippsGFpECBindGxyTblStdSM2 OWNAPI(ippsGFpECBindGxyTblStdSM2)
+#define ippsGFpECGet OWNAPI(ippsGFpECGet)
+#define ippsGFpECGetSubgroup OWNAPI(ippsGFpECGetSubgroup)
+#define ippsGFpECScratchBufferSize OWNAPI(ippsGFpECScratchBufferSize)
+#define ippsGFpECVerify OWNAPI(ippsGFpECVerify)
+#define ippsGFpECPointGetSize OWNAPI(ippsGFpECPointGetSize)
+#define ippsGFpECPointInit OWNAPI(ippsGFpECPointInit)
+#define ippsGFpECSetPointAtInfinity OWNAPI(ippsGFpECSetPointAtInfinity)
+#define ippsGFpECSetPoint OWNAPI(ippsGFpECSetPoint)
+#define ippsGFpECSetPointRegular OWNAPI(ippsGFpECSetPointRegular)
+#define ippsGFpECSetPointRandom OWNAPI(ippsGFpECSetPointRandom)
+#define ippsGFpECMakePoint OWNAPI(ippsGFpECMakePoint)
+#define ippsGFpECSetPointHash OWNAPI(ippsGFpECSetPointHash)
+#define ippsGFpECSetPointHash_rmf OWNAPI(ippsGFpECSetPointHash_rmf)
+#define ippsGFpECGetPoint OWNAPI(ippsGFpECGetPoint)
+#define ippsGFpECGetPointRegular OWNAPI(ippsGFpECGetPointRegular)
+#define ippsGFpECSetPointOctString OWNAPI(ippsGFpECSetPointOctString)
+#define ippsGFpECGetPointOctString OWNAPI(ippsGFpECGetPointOctString)
+#define ippsGFpECTstPoint OWNAPI(ippsGFpECTstPoint)
+#define ippsGFpECTstPointInSubgroup OWNAPI(ippsGFpECTstPointInSubgroup)
+#define ippsGFpECCpyPoint OWNAPI(ippsGFpECCpyPoint)
+#define ippsGFpECCmpPoint OWNAPI(ippsGFpECCmpPoint)
+#define ippsGFpECNegPoint OWNAPI(ippsGFpECNegPoint)
+#define ippsGFpECAddPoint OWNAPI(ippsGFpECAddPoint)
+#define ippsGFpECMulPoint OWNAPI(ippsGFpECMulPoint)
+#define ippsGFpECPrivateKey OWNAPI(ippsGFpECPrivateKey)
+#define ippsGFpECPublicKey OWNAPI(ippsGFpECPublicKey)
+#define ippsGFpECTstKeyPair OWNAPI(ippsGFpECTstKeyPair)
+#define ippsGFpECSharedSecretDH OWNAPI(ippsGFpECSharedSecretDH)
+#define ippsGFpECSharedSecretDHC OWNAPI(ippsGFpECSharedSecretDHC)
+#define ippsGFpECSignDSA OWNAPI(ippsGFpECSignDSA)
+#define ippsGFpECVerifyDSA OWNAPI(ippsGFpECVerifyDSA)
+#define ippsGFpECSignNR OWNAPI(ippsGFpECSignNR)
+#define ippsGFpECVerifyNR OWNAPI(ippsGFpECVerifyNR)
+#define ippsGFpECSignSM2 OWNAPI(ippsGFpECSignSM2)
+#define ippsGFpECVerifySM2 OWNAPI(ippsGFpECVerifySM2)
+#define ippsGFpECESGetSize_SM2 OWNAPI(ippsGFpECESGetSize_SM2)
+#define ippsGFpECESInit_SM2 OWNAPI(ippsGFpECESInit_SM2)
+#define ippsGFpECESSetKey_SM2 OWNAPI(ippsGFpECESSetKey_SM2)
+#define ippsGFpECESStart_SM2 OWNAPI(ippsGFpECESStart_SM2)
+#define ippsGFpECESEncrypt_SM2 OWNAPI(ippsGFpECESEncrypt_SM2)
+#define ippsGFpECESDecrypt_SM2 OWNAPI(ippsGFpECESDecrypt_SM2)
+#define ippsGFpECESFinal_SM2 OWNAPI(ippsGFpECESFinal_SM2)
+#define ippsGFpECESGetBuffersSize_SM2 OWNAPI(ippsGFpECESGetBuffersSize_SM2)
+
+ #include "ippcp.h"
+#endif
+
+/*
+// modes of the CPU feature
+*/
+#define _FEATURE_OFF_ (0) /* feature is OFF a priori */
+#define _FEATURE_ON_ (1) /* feature is ON a priori */
+#define _FEATURE_TICKTOCK_ (2) /* dectect is feature OFF/ON */
+
+#include "pcpvariant.h"
+
+#pragma warning( disable : 4996 4324 4206)
+
+/* ippCP length */
+typedef int cpSize;
+
+/*
+// Common ippCP Macros
+*/
+
+/* size of cache line (bytes) */
+#if (_IPP==_IPP_M5)
+#define CACHE_LINE_SIZE (16)
+#define LOG_CACHE_LINE_SIZE (4)
+#else
+#define CACHE_LINE_SIZE (64)
+#define LOG_CACHE_LINE_SIZE (6)
+#endif
+
+/* swap data & pointers */
+#define SWAP_PTR(ATYPE, pX,pY) { ATYPE* aPtr=(pX); (pX)=(pY); (pY)=aPtr; }
+#define SWAP(x,y) {(x)^=(y); (y)^=(x); (x)^=(y);}
+
+/* alignment value */
+#define ALIGN_VAL ((int)sizeof(void*))
+
+/* bitsize */
+#define BYTESIZE (8)
+#define BITSIZE(x) ((int)(sizeof(x)*BYTESIZE))
+
+/* bit length -> byte/word length conversion */
+#define BITS2WORD8_SIZE(x) (((x)+ 7)>>3)
+#define BITS2WORD16_SIZE(x) (((x)+15)>>4)
+#define BITS2WORD32_SIZE(x) (((x)+31)>>5)
+#define BITS2WORD64_SIZE(x) (((x)+63)>>6)
+
+/* WORD and DWORD manipulators */
+#define LODWORD(x) ((Ipp32u)(x))
+#define HIDWORD(x) ((Ipp32u)(((Ipp64u)(x) >>32) & 0xFFFFFFFF))
+
+#define MAKEHWORD(bLo,bHi) ((Ipp16u)(((Ipp8u)(bLo)) | ((Ipp16u)((Ipp8u)(bHi))) << 8))
+#define MAKEWORD(hLo,hHi) ((Ipp32u)(((Ipp16u)(hLo)) | ((Ipp32u)((Ipp16u)(hHi))) << 16))
+#define MAKEDWORD(wLo,wHi) ((Ipp64u)(((Ipp32u)(wLo)) | ((Ipp64u)((Ipp32u)(wHi))) << 32))
+
+/* extract byte */
+#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n))))
+
+/* hexString <-> Ipp32u conversion */
+#define HSTRING_TO_U32(ptrByte) \
+ ((((ptrByte)[0]) <<24) \
+ +(((ptrByte)[1]) <<16) \
+ +(((ptrByte)[2]) <<8) \
+ +((ptrByte)[3]))
+#define U32_TO_HSTRING(ptrByte, x) \
+ (ptrByte)[0] = (Ipp8u)((x)>>24); \
+ (ptrByte)[1] = (Ipp8u)((x)>>16); \
+ (ptrByte)[2] = (Ipp8u)((x)>>8); \
+ (ptrByte)[3] = (Ipp8u)(x)
+
+/* 32- and 64-bit masks for MSB of nbits-sequence */
+#define MAKEMASK32(nbits) (0xFFFFFFFF >>((32 - ((nbits)&0x1F)) &0x1F))
+#define MAKEMASK64(nbits) (0xFFFFFFFFFFFFFFFF >>((64 - ((nbits)&0x3F)) &0x3F))
+
+/* Logical Shifts (right and left) of WORD */
+#define LSR32(x,nBits) ((x)>>(nBits))
+#define LSL32(x,nBits) ((x)<<(nBits))
+
+/* Rorate (right and left) of WORD */
+#if defined(_MSC_VER) && !defined( __ICL )
+# include <stdlib.h>
+# define ROR32(x, nBits) _lrotr((x),(nBits))
+# define ROL32(x, nBits) _lrotl((x),(nBits))
+#else
+# define ROR32(x, nBits) (LSR32((x),(nBits)) | LSL32((x),32-(nBits)))
+# define ROL32(x, nBits) ROR32((x),(32-(nBits)))
+#endif
+
+/* Logical Shifts (right and left) of DWORD */
+#define LSR64(x,nBits) ((x)>>(nBits))
+#define LSL64(x,nBits) ((x)<<(nBits))
+
+/* Rorate (right and left) of DWORD */
+#define ROR64(x, nBits) (LSR64((x),(nBits)) | LSL64((x),64-(nBits)))
+#define ROL64(x, nBits) ROR64((x),(64-(nBits)))
+
+/* change endian */
+#if defined(_MSC_VER)
+# define ENDIANNESS(x) _byteswap_ulong((x))
+# define ENDIANNESS32(x) ENDIANNESS((x))
+# define ENDIANNESS64(x) _byteswap_uint64((x))
+#elif defined(__ICL)
+# define ENDIANNESS(x) _bswap((x))
+# define ENDIANNESS32(x) ENDIANNESS((x))
+# define ENDIANNESS64(x) _bswap64((x))
+#else
+# define ENDIANNESS(x) ((ROR32((x), 24) & 0x00ff00ff) | (ROR32((x), 8) & 0xff00ff00))
+# define ENDIANNESS32(x) ENDIANNESS((x))
+# define ENDIANNESS64(x) MAKEDWORD(ENDIANNESS(HIDWORD((x))), ENDIANNESS(LODWORD((x))))
+#endif
+
+#define IPP_MAKE_MULTIPLE_OF_8(x) ((x) = ((x)+7)&(~7))
+#define IPP_MAKE_MULTIPLE_OF_16(x) ((x) = ((x)+15)&(~15))
+
+/* define 64-bit constant */
+#if !defined(__GNUC__)
+ #define CONST_64(x) (x) /*(x##i64)*/
+#else
+ #define CONST_64(x) (x##LL)
+#endif
+
+/* define 64-bit constant or pair of 32-bit dependding on architecture */
+#if ((_IPP_ARCH == _IPP_ARCH_EM64T) || (_IPP_ARCH == _IPP_ARCH_LP64) || (_IPP_ARCH == _IPP_ARCH_LRB) || (_IPP_ARCH == _IPP_ARCH_LRB2))
+#define LL(lo,hi) ((Ipp64u)(((Ipp32u)(lo)) | ((Ipp64u)((Ipp32u)(hi))) << 32))
+#define L_(lo) ((Ipp64u)(lo))
+#else
+#define LL(lo,hi) (lo),(hi)
+#define L_(lo) (lo)
+#endif
+
+
+/* test if library's feature is ON */
+int cpGetFeature( Ipp64u Feature );
+/* test CPU crypto features */
+__INLINE Ipp32u IsFeatureEnabled(Ipp64u niMmask)
+{
+ return cpGetFeature(niMmask);
+}
+
+#define IPPCP_GET_NUM_THREADS() ( ippcpGetEnabledNumThreads() )
+#define IPPCP_OMP_NUM_THREADS() num_threads( IPPCP_GET_NUM_THREADS() )
+#define IPPCP_OMP_LIMIT_MAX_NUM_THREADS(n) num_threads( IPP_MIN(IPPCP_GET_NUM_THREADS(),(n)))
+
+/* copy under mask */
+#define MASKED_COPY_BNU(dst, mask, src1, src2, len) { \
+ cpSize i; \
+ for(i=0; i<(len); i++) (dst)[i] = ((mask) & (src1)[i]) | (~(mask) & (src2)[i]); \
+}
+
+#if !defined( _M_X64 ) && defined ( _MSC_VER ) && !defined(__INTEL_COMPILER)
+#if (_AES_NI_ENABLING_ == _FEATURE_ON_) || \
+ (_AES_NI_ENABLING_ == _FEATURE_TICKTOCK_) || (_IPP >= _IPP_W7)
+__inline __m128i
+_mm_cvtsi64_si128(__int64 a)
+{
+ __m128i x;
+ x.m128i_i64[0] = a;
+ x.m128i_i64[1] = 0;
+ return x;
+}
+#endif
+#endif
+
+#endif /* __OWNCP_H__ */
diff --git a/ext/ipp/sources/ippcp/pcpaes_cbc.h b/ext/ipp/sources/ippcp/pcpaes_cbc.h
new file mode 100644
index 0000000..976740f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_cbc.h
@@ -0,0 +1,215 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES encryption/decryption (CBC mode)
+// AES encryption/decryption (CBC-CS mode)
+//
+// Contents:
+// ippsAESDecryptCBC()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpaesm.h"
+#include "pcptool.h"
+
+#if !defined(_PCP_AES_CBC_H_)
+#define _PCP_AES_CBC_H_
+
+#if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPOSITE_GF_)
+# pragma message("_ALG_AES_SAFE_COMPOSITE_GF_ enabled")
+#elif (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+# pragma message("_ALG_AES_SAFE_COMPACT_SBOX_ enabled")
+# include "pcprijtables.h"
+#else
+# pragma message("_ALG_AES_SAFE_ disabled")
+#endif
+
+/*
+// AES-CBC decryption
+//
+// Parameters:
+// pIV pointer to the initialization vector
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// nBlocks number of decrypted data blocks
+// pCtx pointer to the AES context
+*/
+static
+void cpDecryptAES_cbc(const Ipp8u* pIV,
+ const Ipp8u* pSrc, Ipp8u* pDst, int nBlocks,
+ const IppsAESSpec* pCtx)
+{
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ /* use pipelined version is possible */
+ if(AES_NI_ENABLED==RIJ_AESNI(pCtx)) {
+ DecryptCBC_RIJ128pipe_AES_NI(pSrc, pDst, RIJ_NR(pCtx), RIJ_DKEYS(pCtx), nBlocks*MBS_RIJ128, pIV);
+ }
+ else
+#endif
+ {
+ /* setup decoder method */
+ RijnCipher decoder = RIJ_DECODER(pCtx);
+
+ /* copy IV */
+ Ipp32u iv[NB(128)];
+ CopyBlock16(pIV, iv);
+
+ /* not inplace block-by-block decryption */
+ if(pSrc != pDst) {
+ while(nBlocks) {
+ //decoder((const Ipp32u*)pSrc, (Ipp32u*)pDst, RIJ_NR(pCtx), RIJ_DKEYS(pCtx), (const Ipp32u (*)[256])RIJ_DEC_SBOX(pCtx));
+ #if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+ decoder(pSrc, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijDecSbox/*NULL*/);
+ #else
+ decoder(pSrc, pDst, RIJ_NR(pCtx), RIJ_DKEYS(pCtx), NULL);
+ #endif
+
+ ((Ipp32u*)pDst)[0] ^= iv[0];
+ ((Ipp32u*)pDst)[1] ^= iv[1];
+ ((Ipp32u*)pDst)[2] ^= iv[2];
+ ((Ipp32u*)pDst)[3] ^= iv[3];
+
+ iv[0] = ((Ipp32u*)pSrc)[0];
+ iv[1] = ((Ipp32u*)pSrc)[1];
+ iv[2] = ((Ipp32u*)pSrc)[2];
+ iv[3] = ((Ipp32u*)pSrc)[3];
+
+ pSrc += MBS_RIJ128;
+ pDst += MBS_RIJ128;
+ nBlocks--;
+ }
+ }
+
+ /* inplace block-by-block decryption */
+ else {
+ Ipp32u tmpInp[NB(128)];
+ Ipp32u tmpOut[NB(128)];
+
+ while(nBlocks) {
+ CopyBlock16(pSrc, tmpInp);
+ //decoder(tmpInp, tmpOut, RIJ_NR(pCtx), RIJ_DKEYS(pCtx), (const Ipp32u (*)[256])RIJ_DEC_SBOX(pCtx));
+ #if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+ decoder((Ipp8u*)tmpInp, (Ipp8u*)tmpOut, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijDecSbox/*NULL*/);
+ #else
+ decoder((Ipp8u*)tmpInp, (Ipp8u*)tmpOut, RIJ_NR(pCtx), RIJ_DKEYS(pCtx), NULL);
+ #endif
+
+ tmpOut[0] ^= iv[0];
+ tmpOut[1] ^= iv[1];
+ tmpOut[2] ^= iv[2];
+ tmpOut[3] ^= iv[3];
+
+ CopyBlock16(tmpOut, pDst);
+
+ iv[0] = tmpInp[0];
+ iv[1] = tmpInp[1];
+ iv[2] = tmpInp[2];
+ iv[3] = tmpInp[3];
+
+ pSrc += MBS_RIJ128;
+ pDst += MBS_RIJ128;
+ nBlocks--;
+ }
+ }
+ }
+}
+
+
+/*
+// AES-CBC ecnryption
+//
+// Parameters:
+// pIV pointer to the initialization vector
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// nBlocks number of ecnrypted data blocks
+// pCtx pointer to the AES context
+*/
+static
+void cpEncryptAES_cbc(const Ipp8u* pIV,
+ const Ipp8u* pSrc, Ipp8u* pDst, int nBlocks, const IppsAESSpec* pCtx)
+{
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ if(AES_NI_ENABLED==RIJ_AESNI(pCtx)) {
+ EncryptCBC_RIJ128_AES_NI(pSrc, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), nBlocks*MBS_RIJ128, pIV);
+ }
+ else
+#endif
+ {
+ /* setup encoder method */
+ RijnCipher encoder = RIJ_ENCODER(pCtx);
+
+ /* read IV */
+ Ipp32u iv[NB(128)];
+ CopyBlock16(pIV, iv);
+
+ /* block-by-block encryption */
+ while(nBlocks) {
+ iv[0] ^= ((Ipp32u*)pSrc)[0];
+ iv[1] ^= ((Ipp32u*)pSrc)[1];
+ iv[2] ^= ((Ipp32u*)pSrc)[2];
+ iv[3] ^= ((Ipp32u*)pSrc)[3];
+
+ //encoder(iv, (Ipp32u*)pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), (const Ipp32u (*)[256])RIJ_ENC_SBOX(pCtx));
+ #if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+ encoder((Ipp8u*)iv, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox/*NULL*/);
+ #else
+ encoder((Ipp8u*)iv, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), NULL);
+ #endif
+
+ iv[0] = ((Ipp32u*)pDst)[0];
+ iv[1] = ((Ipp32u*)pDst)[1];
+ iv[2] = ((Ipp32u*)pDst)[2];
+ iv[3] = ((Ipp32u*)pDst)[3];
+
+ pSrc += MBS_RIJ128;
+ pDst += MBS_RIJ128;
+ nBlocks--;
+ }
+ }
+}
+
+#endif /* #if !defined(_PCP_AES_CBC_H_) */
diff --git a/ext/ipp/sources/ippcp/pcpaes_cmac_stuff.h b/ext/ipp/sources/ippcp/pcpaes_cmac_stuff.h
new file mode 100644
index 0000000..b21f1c8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_cmac_stuff.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES-CMAC Functions
+//
+// Contents:
+// init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpcmac.h"
+#include "pcpaesm.h"
+#include "pcptool.h"
+
+#if !defined(_PCP_AES_CMAC_STUFF_H_)
+#define _PCP_AES_CMAC_STUFF_H_
+
+__INLINE int cpSizeofCtx_AESCMAC(void)
+{
+ return sizeof(IppsAES_CMACState) + AESCMAC_ALIGNMENT-1;
+}
+
+static void init(IppsAES_CMACState* pCtx)
+{
+ /* buffer is empty */
+ CMAC_INDX(pCtx) = 0;
+ /* zeros MAC */
+ PaddBlock(0, CMAC_MAC(pCtx), MBS_RIJ128);
+}
+
+#endif /* #if !defined(_PCP_AES_CMAC_STUFF_H_) */
diff --git a/ext/ipp/sources/ippcp/pcpaes_ctr_process.h b/ext/ipp/sources/ippcp/pcpaes_ctr_process.h
new file mode 100644
index 0000000..5147a62
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_ctr_process.h
@@ -0,0 +1,269 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES encryption/decryption (CTR mode)
+//
+// Contents:
+// cpProcessAES_ctr()
+// cpProcessAES_ctr128()
+//
+*/
+
+#if !defined(_OPENMP)
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpaesm.h"
+#include "pcptool.h"
+
+#if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPOSITE_GF_)
+# pragma message("_ALG_AES_SAFE_COMPOSITE_GF_ enabled")
+#elif (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+# pragma message("_ALG_AES_SAFE_COMPACT_SBOX_ enabled")
+# include "pcprijtables.h"
+#else
+# pragma message("_ALG_AES_SAFE_ disabled")
+#endif
+
+/*
+// AES-CRT processing.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx == NULL
+// pSrc == NULL
+// pDst == NULL
+// pCtrValue ==NULL
+// ippStsContextMatchErr !VALID_AES_ID()
+// ippStsLengthErr len <1
+// ippStsCTRSizeErr 128 < ctrNumBitSize < 1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// dataLen input/output buffer length (in bytes)
+// pCtx pointer to rge AES context
+// pCtrValue pointer to the counter block
+// ctrNumBitSize counter block size (bits)
+//
+// Note:
+// counter will updated on return
+//
+*/
+__INLINE void MaskCounter128(Ipp8u* pMaskIV, int ctrBtSize)
+{
+ /* construct ctr mask */
+ int maskPosition = (MBS_RIJ128*8-ctrBtSize)/8;
+ Ipp8u maskValue = (Ipp8u)(0xFF >> (MBS_RIJ128*8-ctrBtSize)%8 );
+
+ Ipp8u maskIV[MBS_RIJ128];
+ int n;
+ for(n=0; n<MBS_RIJ128; n++) {
+ int d = n - maskPosition;
+ Ipp8u storedMaskValue = maskValue & ~cpIsMsb_ct(d);
+ pMaskIV[n] = storedMaskValue;
+ maskValue |= ~cpIsMsb_ct(d);
+ }
+}
+
+static
+IppStatus cpProcessAES_ctr(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
+ const IppsAESSpec* pCtx,
+ Ipp8u* pCtrValue, int ctrNumBitSize)
+{
+ /* test context */
+ IPP_BAD_PTR1_RET(pCtx);
+ /* use aligned AES context */
+ pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtx, AES_ALIGNMENT) );
+ /* test the context ID */
+ IPP_BADARG_RET(!VALID_AES_ID(pCtx), ippStsContextMatchErr);
+
+ /* test source, target and counter block pointers */
+ IPP_BAD_PTR3_RET(pSrc, pDst, pCtrValue);
+ /* test stream length */
+ IPP_BADARG_RET((dataLen<1), ippStsLengthErr);
+
+ /* test counter block size */
+ IPP_BADARG_RET(((MBS_RIJ128*8)<ctrNumBitSize)||(ctrNumBitSize<1), ippStsCTRSizeErr);
+
+ #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ /* use pipelined version if possible */
+ if(AES_NI_ENABLED==RIJ_AESNI(pCtx)) {
+ /* construct ctr mask */
+ #if 0
+ int maskPosition = (MBS_RIJ128*8-ctrNumBitSize)/8;
+ Ipp8u maskValue = (Ipp8u)(0xFF >> (MBS_RIJ128*8-ctrNumBitSize)%8 );
+
+ Ipp8u maskIV[MBS_RIJ128];
+ int n;
+ for(n=0; n<maskPosition; n++)
+ maskIV[n] = 0;
+ maskIV[maskPosition] = maskValue;
+ for(n=maskPosition+1; n<MBS_RIJ128; n++)
+ maskIV[n] = 0xFF;
+ #endif
+
+ Ipp8u maskIV[MBS_RIJ128];
+ MaskCounter128(maskIV, ctrNumBitSize); /* const-exe-time version */
+
+ EncryptCTR_RIJ128pipe_AES_NI(pSrc, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), dataLen, pCtrValue, maskIV);
+ return ippStsNoErr;
+ }
+ else
+ #endif
+ {
+ Ipp32u counter[NB(128)];
+ Ipp32u output[NB(128)];
+
+ /* setup encoder method */
+ RijnCipher encoder = RIJ_ENCODER(pCtx);
+
+ /* copy counter */
+ CopyBlock16(pCtrValue, counter);
+
+ /*
+ // encrypt block-by-block aligned streams
+ */
+ while(dataLen>= MBS_RIJ128) {
+ /* encrypt counter block */
+ //encoder(counter, output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), (const Ipp32u (*)[256])RIJ_ENC_SBOX(pCtx));
+ #if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+ encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox/*NULL*/);
+ #else
+ encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), NULL);
+ #endif
+
+ /* compute ciphertext block */
+ if( !(IPP_UINT_PTR(pSrc) & 0x3) && !(IPP_UINT_PTR(pDst) & 0x3)) {
+ ((Ipp32u*)pDst)[0] = output[0]^((Ipp32u*)pSrc)[0];
+ ((Ipp32u*)pDst)[1] = output[1]^((Ipp32u*)pSrc)[1];
+ ((Ipp32u*)pDst)[2] = output[2]^((Ipp32u*)pSrc)[2];
+ ((Ipp32u*)pDst)[3] = output[3]^((Ipp32u*)pSrc)[3];
+ }
+ else
+ XorBlock16(pSrc, output, pDst);
+ /* encrement counter block */
+ StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize);
+
+ pSrc += MBS_RIJ128;
+ pDst += MBS_RIJ128;
+ dataLen -= MBS_RIJ128;
+ }
+ /*
+ // encrypt last data block
+ */
+ if(dataLen) {
+ /* encrypt counter block */
+ //encoder(counter, output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), (const Ipp32u (*)[256])RIJ_ENC_SBOX(pCtx));
+ #if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+ encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox/*NULL*/);
+ #else
+ encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), NULL);
+ #endif
+
+ /* compute ciphertext block */
+ XorBlock(pSrc, output, pDst,dataLen);
+ /* encrement counter block */
+ StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize);
+ }
+
+ /* update counter */
+ CopyBlock16(counter, pCtrValue);
+
+ return ippStsNoErr;
+ }
+}
+
+#if (_IPP32E>=_IPP32E_Y8)
+
+/*
+// special version: 128-bit counter
+*/
+static
+IppStatus cpProcessAES_ctr128(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen, const IppsAESSpec* pCtx, Ipp8u* pCtrValue)
+{
+ /* test context */
+ IPP_BAD_PTR1_RET(pCtx);
+ /* use aligned AES context */
+ pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtx, AES_ALIGNMENT) );
+ /* test the context ID */
+ IPP_BADARG_RET(!VALID_AES_ID(pCtx), ippStsContextMatchErr);
+
+ /* test source, target and counter block pointers */
+ IPP_BAD_PTR3_RET(pSrc, pDst, pCtrValue);
+ /* test stream length */
+ IPP_BADARG_RET((dataLen<1), ippStsLengthErr);
+
+ {
+ while(dataLen>=MBS_RIJ128) {
+ Ipp32u blocks = dataLen>>4; /* number of blocks per loop processing */
+
+ /* low LE 32 bit of counter */
+ Ipp32u ctr32 = ((Ipp32u*)(pCtrValue))[3];
+ ctr32 = ENDIANNESS32(ctr32);
+
+ /* compute number of locks being processed without ctr32 overflow */
+ ctr32 += blocks;
+ if(ctr32 < blocks)
+ blocks -= ctr32;
+
+ EncryptStreamCTR32_AES_NI(pSrc, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), blocks*MBS_RIJ128, pCtrValue);
+
+ pSrc += blocks*MBS_RIJ128;
+ pDst += blocks*MBS_RIJ128;
+ dataLen -= blocks*MBS_RIJ128;
+ }
+
+ if(dataLen) {
+ EncryptStreamCTR32_AES_NI(pSrc, pDst, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), dataLen, pCtrValue);
+ }
+
+ return ippStsNoErr;
+ }
+}
+
+#endif /* #if (_IPP32E>=_IPP32E_Y8) */
+
+#endif /* #if !defined(_OPENMP) */
+
diff --git a/ext/ipp/sources/ippcp/pcpaes_keys_ni.h b/ext/ipp/sources/ippcp/pcpaes_keys_ni.h
new file mode 100644
index 0000000..41b2406
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_keys_ni.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive. AES keys expansion
+//
+// Contents:
+// cpExpandAesKey_NI()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpaesm.h"
+
+#if !defined (_PCP_AES_KEYS_NI_H)
+#define _PCP_AES_KEYS_NI_H
+
+#if (_AES_NI_ENABLING_==_FEATURE_ON_) || (_AES_NI_ENABLING_==_FEATURE_TICKTOCK_)
+
+//////////////////////////////////////////////////////////////////////
+#define cpExpandAesKey_NI OWNAPI(cpExpandAesKey_NI)
+void cpExpandAesKey_NI(const Ipp8u* pSecret, IppsAESSpec* pCtx);
+#define aes_DecKeyExpansion_NI OWNAPI(aes_DecKeyExpansion_NI)
+void aes_DecKeyExpansion_NI(Ipp8u* decKeys, const Ipp8u* encKeys, int nr);
+#define aes128_KeyExpansion_NI OWNAPI(aes128_KeyExpansion_NI)
+void aes128_KeyExpansion_NI(Ipp8u* keyExp, const Ipp8u* userkey);
+#define aes192_KeyExpansion_NI OWNAPI(aes192_KeyExpansion_NI)
+void aes192_KeyExpansion_NI(Ipp8u* keyExp, const Ipp8u* userkey);
+#define aes256_KeyExpansion_NI OWNAPI(aes256_KeyExpansion_NI)
+void aes256_KeyExpansion_NI(Ipp8u* keyExp, const Ipp8u* userkey);
+
+#endif /* #if (_AES_NI_ENABLING_==_FEATURE_ON_) || (_AES_NI_ENABLING_==_FEATURE_TICKTOCK_) */
+
+#endif /* #if !defined (_PCP_AES_KEYS_NI_H) */
diff --git a/ext/ipp/sources/ippcp/pcpaes_ofb.h b/ext/ipp/sources/ippcp/pcpaes_ofb.h
new file mode 100644
index 0000000..0cf0c2a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_ofb.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES encryption/decryption (OFB mode)
+//
+// Contents:
+// cpProcessAES_ofb8()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+
+#if !defined(_PCP_AES_OFB_H)
+#define _PCP_AES_OFB_H
+
+/*
+// AES-OFB ecnryption/decryption
+//
+// Parameters:
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// dataLen input/output buffer length (in bytes)
+// ofbBlkSize ofb block size (in bytes)
+// pCtx pointer to the AES context
+// pIV pointer to the initialization vector
+*/
+#define cpProcessAES_ofb8 OWNAPI(cpProcessAES_ofb8)
+void cpProcessAES_ofb8(const Ipp8u *pSrc, Ipp8u *pDst, int dataLen, int ofbBlkSize, const IppsAESSpec* pCtx, Ipp8u* pIV);
+
+#endif /* #if !defined(_PCP_AES_OFB_H) */ \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpaes_sivstuff.h b/ext/ipp/sources/ippcp/pcpaes_sivstuff.h
new file mode 100644
index 0000000..6cda020
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaes_sivstuff.h
@@ -0,0 +1,114 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES-SIV Functions (RFC 5297)
+//
+// Contents:
+// Stuff()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpcmac.h"
+#include "pcpaesm.h"
+#include "pcptool.h"
+
+#if !defined(_PCP_AES_SIV_STUFF_H_)
+
+#define _PCP_AES_SIV_STUFF_H_
+////////////////////////////////////////////////////////////
+__INLINE void cpAES_CMAC(Ipp8u mac[MBS_RIJ128], const Ipp8u* pSrc, int len, IppsAES_CMACState* pCtx)
+{
+ ippsAES_CMACUpdate(pSrc, len, pCtx);
+ ippsAES_CMACFinal(mac, MBS_RIJ128, pCtx);
+}
+__INLINE IppStatus cpAES_S2V_init(Ipp8u v[MBS_RIJ128], const Ipp8u* pKey, int keyLen, IppsAES_CMACState* pCtx, int ctxSize)
+{
+ IppStatus sts = ippsAES_CMACInit(pKey, keyLen, pCtx, ctxSize);
+ if(ippStsNoErr==sts) {
+ PaddBlock(0, v, MBS_RIJ128);
+ cpAES_CMAC(v, v, MBS_RIJ128, pCtx);
+ }
+ return sts;
+}
+__INLINE Ipp8u* double16(Ipp8u out[MBS_RIJ128], const Ipp8u inp[MBS_RIJ128])
+{
+ /* double inp */
+ Ipp32u carry = 0;
+ int n;
+ for(n=0; n<MBS_RIJ128; n++) {
+ Ipp32u x = inp[MBS_RIJ128-1-n] + inp[MBS_RIJ128-1-n] + carry;
+ out[MBS_RIJ128-1-n] = (Ipp8u)x;
+ carry = (x>>8) & 0xFF;
+ }
+
+ out[MBS_RIJ128-1] ^= ((Ipp8u)(0-carry) & 0x87);
+ return out;
+}
+__INLINE void cpAES_S2V_update(Ipp8u v[MBS_RIJ128], const Ipp8u* pSrc, int len, IppsAES_CMACState* pCtx)
+{
+ Ipp8u t[MBS_RIJ128];
+ cpAES_CMAC(t, pSrc, len, pCtx);
+ double16(v, v);
+ XorBlock16(v, t, v);
+}
+
+static void cpAES_S2V_final(Ipp8u v[MBS_RIJ128], const Ipp8u* pSrc, int len, IppsAES_CMACState* pCtx)
+{
+ Ipp8u t[MBS_RIJ128];
+
+ if(len>=MBS_RIJ128) {
+ ippsAES_CMACUpdate(pSrc, len-MBS_RIJ128, pCtx);
+ XorBlock16(pSrc+len-MBS_RIJ128, v, t);
+ }
+ else {
+ double16(t, v);
+ XorBlock(pSrc, t, t, len);
+ t[len] ^= 0x80;
+ }
+ cpAES_CMAC(v, t, MBS_RIJ128, pCtx);
+}
+
+#endif /*_PCP_AES_SIV_STUFF_H_*/
diff --git a/ext/ipp/sources/ippcp/pcpaesauthccm.h b/ext/ipp/sources/ippcp/pcpaesauthccm.h
new file mode 100644
index 0000000..fe10762
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaesauthccm.h
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Message Authentication Algorithm
+// Internal Definitions and Internal Functions Prototypes
+//
+//
+*/
+
+#if !defined(_CP_AES_CCM_H)
+#define _CP_AES_CCM_H
+
+#include "pcprij.h"
+#include "pcpaesm.h"
+
+struct _cpAES_CCM {
+ IppCtxId idCtx; /* CCM ID */
+
+ Ipp64u msgLen; /* length of message to be processed */
+ Ipp64u lenProcessed; /* message length has been processed */
+ Ipp32u tagLen; /* length of authentication tag */
+ Ipp32u counterVal; /* currnt couter value */
+ Ipp8u ctr0[MBS_RIJ128]; /* counter value */
+ Ipp8u s0[MBS_RIJ128]; /* S0 = ENC(CTR0) content */
+ Ipp8u si[MBS_RIJ128]; /* Si = ENC(CTRi) content */
+ Ipp8u blk[MBS_RIJ128]; /* temporary data container */
+ Ipp8u mac[MBS_RIJ128]; /* current MAC value */
+
+ Ipp8u cipher[sizeof(IppsAESSpec)+AES_ALIGNMENT-1];
+};
+
+/* alignment */
+#define AESCCM_ALIGNMENT ((int)(sizeof(void*)))
+
+/*
+// access macros
+*/
+#define AESCCM_ID(stt) ((stt)->idCtx)
+#define AESCCM_MSGLEN(stt) ((stt)->msgLen)
+#define AESCCM_LENPRO(stt) ((stt)->lenProcessed)
+#define AESCCM_TAGLEN(stt) ((stt)->tagLen)
+#define AESCCM_COUNTER(stt) ((stt)->counterVal)
+#define AESCCM_CTR0(stt) ((stt)->ctr0)
+#define AESCCM_S0(stt) ((stt)->s0)
+#define AESCCM_Si(stt) ((stt)->si)
+#define AESCCM_BLK(stt) ((stt)->blk)
+#define AESCCM_MAC(stt) ((stt)->mac)
+#define AESCCM_CIPHER(stt) (IppsAESSpec*)(&((stt)->cipher))
+#define AESCCM_CIPHER_ALIGNED(stt) (IppsAESSpec*)( IPP_ALIGNED_PTR( ((stt)->cipher), AES_ALIGNMENT ) )
+
+/* valid context ID */
+#define VALID_AESCCM_ID(ctx) (AESCCM_ID((ctx))==idCtxAESCCM)
+
+/*
+// Internal functions
+*/
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+#define AuthEncrypt_RIJ128_AES_NI OWNAPI(AuthEncrypt_RIJ128_AES_NI)
+ void AuthEncrypt_RIJ128_AES_NI(const Ipp8u* inpBlk, Ipp8u* outBlk, int nr, const void* pRKey, Ipp32u len, void* pLocalCtx);
+#define DecryptAuth_RIJ128_AES_NI OWNAPI(DecryptAuth_RIJ128_AES_NI)
+ void DecryptAuth_RIJ128_AES_NI(const Ipp8u* inpBlk, Ipp8u* outBlk, int nr, const void* pRKey, Ipp32u len, void* pLocalCtx);
+#endif
+
+/* Counter block formatter */
+static Ipp8u* CounterEnc(Ipp32u* pBuffer, int fmt, Ipp64u counter)
+{
+ #if (IPP_ENDIAN == IPP_LITTLE_ENDIAN)
+ pBuffer[0] = ENDIANNESS(HIDWORD(counter));
+ pBuffer[1] = ENDIANNESS(LODWORD(counter));
+ #else
+ pBuffer[0] = HIDWORD(counter);
+ pBuffer[1] = LODWORD(counter);
+ #endif
+ return (Ipp8u*)pBuffer + 8 - fmt;
+}
+
+static int cpSizeofCtx_AESCCM(void)
+{
+ return sizeof(IppsAES_CCMState) + AESCCM_ALIGNMENT-1;
+}
+
+#endif /* _CP_AES_CCM_H*/
diff --git a/ext/ipp/sources/ippcp/pcpaesauthgcm.h b/ext/ipp/sources/ippcp/pcpaesauthgcm.h
new file mode 100644
index 0000000..d6cb24c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaesauthgcm.h
@@ -0,0 +1,204 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Message Authentication Algorithm
+// Internal Definitions and Internal Functions Prototypes
+//
+//
+*/
+
+#if !defined(_CP_AESAUTH_GCM_H)
+#define _CP_AESAUTH_GCM_H
+
+#include "owncp.h"
+#include "pcpaesm.h"
+
+#define BLOCK_SIZE (MBS_RIJ128)
+
+/* GCM Hash prototype: GHash = GHash*HKey mod G() */
+typedef void (*MulGcm_)(Ipp8u* pGHash, const Ipp8u* pHKey, const void* pParam);
+
+/* GCM Authentication prototype: GHash = (GHash^src[])*HKey mod G() */
+typedef void (*Auth_)(Ipp8u* pHash, const Ipp8u* pSrc, int len, const Ipp8u* pHKey, const void* pParam);
+
+/* GCM Encrypt_Authentication prototype */
+typedef void (*Encrypt_)(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+
+/* GCM Authentication_Decrypt prototype */
+typedef void (*Decrypt_)(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+
+typedef enum {
+ GcmInit,
+ GcmIVprocessing,
+ GcmAADprocessing,
+ GcmTXTprocessing
+} GcmState;
+
+struct _cpAES_GCM {
+ IppCtxId idCtx; /* AES-GCM id */
+ GcmState state; /* GCM state: Init, IV|AAD|TXT proccessing */
+ Ipp64u ivLen; /* IV length (bytes) */
+ Ipp64u aadLen; /* header length (bytes) */
+ Ipp64u txtLen; /* text length (bytes) */
+
+ int bufLen; /* staff buffer length */
+ __ALIGN16 /* aligned buffers */
+ Ipp8u counter[BLOCK_SIZE]; /* counter */
+ Ipp8u ecounter0[BLOCK_SIZE]; /* encrypted initial counter */
+ Ipp8u ecounter[BLOCK_SIZE]; /* encrypted counter */
+ Ipp8u ghash[BLOCK_SIZE]; /* ghash accumulator */
+
+ MulGcm_ hashFun; /* AES-GCM mul function */
+ Auth_ authFun; /* authentication function */
+ Encrypt_ encFun; /* encryption & authentication */
+ Decrypt_ decFun; /* authentication & decryption */
+
+ __ALIGN16 /* aligned AES context */
+ IppsAESSpec cipher;
+
+ __ALIGN16 /* aligned pre-computed data: */
+ Ipp8u multiplier[BLOCK_SIZE]; /* - (default) hKey */
+ /* - (ase_ni) hKey*t, (hKey*t)^2, (hKey*t)^4 */
+ /* - (safe) hKey*(t^i), i=0,...,127 */
+};
+
+#define CTR_POS 12
+
+/* alignment */
+#define AESGCM_ALIGNMENT (16)
+
+#define PRECOMP_DATA_SIZE_AES_NI_AESGCM (BLOCK_SIZE*4)
+#define PRECOMP_DATA_SIZE_FAST2K (BLOCK_SIZE*128)
+
+/*
+// Useful macros
+*/
+#define AESGCM_ID(stt) ((stt)->idCtx)
+#define AESGCM_STATE(stt) ((stt)->state)
+
+#define AESGCM_IV_LEN(stt) ((stt)->ivLen)
+#define AESGCM_AAD_LEN(stt) ((stt)->aadLen)
+#define AESGCM_TXT_LEN(stt) ((stt)->txtLen)
+
+#define AESGCM_BUFLEN(stt) ((stt)->bufLen)
+#define AESGCM_COUNTER(stt) ((stt)->counter)
+#define AESGCM_ECOUNTER0(stt) ((stt)->ecounter0)
+#define AESGCM_ECOUNTER(stt) ((stt)->ecounter)
+#define AESGCM_GHASH(stt) ((stt)->ghash)
+
+#define AESGCM_HASH(stt) ((stt)->hashFun)
+#define AESGCM_AUTH(stt) ((stt)->authFun)
+#define AESGCM_ENC(stt) ((stt)->encFun)
+#define AESGCM_DEC(stt) ((stt)->decFun)
+
+#define AESGCM_CIPHER(stt) (IppsAESSpec*)(&((stt)->cipher))
+
+#define AESGCM_HKEY(stt) ((stt)->multiplier)
+#define AESGCM_CPWR(stt) ((stt)->multiplier)
+#define AES_GCM_MTBL(stt) ((stt)->multiplier)
+
+#define AESGCM_VALID_ID(stt) (AESGCM_ID((stt))==idCtxAESGCM)
+
+
+__INLINE void IncrementCounter32(Ipp8u* pCtr)
+{
+ int i;
+ for(i=BLOCK_SIZE-1; i>=CTR_POS && 0==(Ipp8u)(++pCtr[i]); i--) ;
+}
+
+
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+#define AesGcmPrecompute_avx OWNAPI(AesGcmPrecompute_avx)
+ void AesGcmPrecompute_avx(Ipp8u* pPrecomputeData, const Ipp8u* pHKey);
+#define AesGcmMulGcm_avx OWNAPI(AesGcmMulGcm_avx)
+ void AesGcmMulGcm_avx(Ipp8u* pGhash, const Ipp8u* pHkey, const void* pParam);
+#define AesGcmAuth_avx OWNAPI(AesGcmAuth_avx)
+ void AesGcmAuth_avx(Ipp8u* pGhash, const Ipp8u* pSrc, int len, const Ipp8u* pHkey, const void* pParam);
+#define wrpAesGcmEnc_avx OWNAPI(wrpAesGcmEnc_avx)
+ void wrpAesGcmEnc_avx(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+#define wrpAesGcmDec_avx OWNAPI(wrpAesGcmDec_avx)
+ void wrpAesGcmDec_avx(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+#define AesGcmEnc_avx OWNAPI(AesGcmEnc_avx)
+ void AesGcmEnc_avx(Ipp8u* pDst, const Ipp8u* pSrc, int len,
+ RijnCipher cipher, int nr, const Ipp8u* pKeys,
+ Ipp8u* pGhash, Ipp8u* pCnt, Ipp8u* pECnt, const Ipp8u* pMuls);
+#define AesGcmDec_avx OWNAPI(AesGcmDec_avx)
+ void AesGcmDec_avx(Ipp8u* pDst, const Ipp8u* pSrc, int len,
+ RijnCipher cipher, int nr, const Ipp8u* pKeys,
+ Ipp8u* pGhash, Ipp8u* pCnt, Ipp8u* pECnt, const Ipp8u* pMuls);
+#endif
+
+#define AesGcmPrecompute_table2K OWNAPI(AesGcmPrecompute_table2K)
+ void AesGcmPrecompute_table2K(Ipp8u* pPrecomputeData, const Ipp8u* pHKey);
+#define AesGcmMulGcm_table2K OWNAPI(AesGcmMulGcm_table2K)
+ void AesGcmMulGcm_table2K(Ipp8u* pGhash, const Ipp8u* pHkey, const void* pParam);
+#define AesGcmAuth_table2K OWNAPI(AesGcmAuth_table2K)
+ void AesGcmAuth_table2K(Ipp8u* pGhash, const Ipp8u* pSrc, int len, const Ipp8u* pHkey, const void* pParam);
+#define wrpAesGcmEnc_table2K OWNAPI(wrpAesGcmEnc_table2K)
+ void wrpAesGcmEnc_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+#define wrpAesGcmDec_table2K OWNAPI(wrpAesGcmDec_table2K)
+ void wrpAesGcmDec_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
+
+extern const Ipp16u AesGcmConst_table[256]; /* precomputed reduction table */
+
+static int cpSizeofCtx_AESGCM(void)
+{
+ int precomp_size;
+
+ #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ if( IsFeatureEnabled(ippCPUID_AES|ippCPUID_CLMUL) )
+ precomp_size = PRECOMP_DATA_SIZE_AES_NI_AESGCM;
+ else
+ #endif
+ precomp_size = PRECOMP_DATA_SIZE_FAST2K;
+
+ /* decrease precomp_size as soon as BLOCK_SIZE bytes already reserved in context */
+ precomp_size -= BLOCK_SIZE;
+
+ return sizeof(IppsAES_GCMState)
+ +precomp_size
+ +AESGCM_ALIGNMENT-1;
+}
+
+#endif /* _CP_AESAUTH_GCM_H*/
diff --git a/ext/ipp/sources/ippcp/pcpaesm.h b/ext/ipp/sources/ippcp/pcpaesm.h
new file mode 100644
index 0000000..2d6dd50
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaesm.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal AES Function Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_AES_H)
+#define _PCP_AES_H
+
+#include "pcprij.h"
+
+/* Intel(R) AES New Instructions (Intel(R) AES-NI) flag */
+#define AES_NI_ENABLED (ippCPUID_AES)
+
+/* alignment of AES context */
+#define AES_ALIGNMENT (RIJ_ALIGNMENT)
+
+/* valid AES context ID */
+#define VALID_AES_ID(ctx) (RIJ_ID((ctx))==idCtxRijndael)
+
+/* size of AES context */
+__INLINE int cpSizeofCtx_AES(void)
+{
+ return sizeof(IppsAESSpec)
+ +(AES_ALIGNMENT-1);
+}
+
+#endif /* _PCP_AES_H */
diff --git a/ext/ipp/sources/ippcp/pcpaesmxts.h b/ext/ipp/sources/ippcp/pcpaesmxts.h
new file mode 100644
index 0000000..d6c8ba7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaesmxts.h
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES-XTS Internal Definitions
+//
+//
+*/
+
+#if !defined(_PCP_AES_XTS_H)
+#define _PCP_AES_XTS_H
+
+#include "owncp.h"
+#include "pcpaesm.h"
+
+#define _NEW_XTS_API_3
+#if defined (_NEW_XTS_API_3)
+/*
+// AES-XTS State
+*/
+#if !defined(AES_BLK_SIZE)
+#define AES_BLK_SIZE (IPP_AES_BLOCK_BITSIZE/BITSIZE(Ipp8u))
+#endif
+
+#define AES_BLKS_PER_BUFFER (32)
+
+struct _cpAES_XTS
+{
+ IppCtxId idCtx;
+ int duBitsize; /* size of data unit (in bits) */
+ __ALIGN16 IppsAESSpec datumAES; /* datum AES context */
+ __ALIGN16 IppsAESSpec tweakAES; /* tweak AES context */
+};
+
+/* valid AES_XTS context ID */
+#define VALID_AES_XTS_ID(ctx) ((ctx)->idCtx==idCtxAESXTS)
+
+/* size of AES-XTS context */
+__INLINE int cpSizeof_AES_XTS_Ctx(void)
+{
+ return sizeof(IppsAES_XTSSpec) +(AES_ALIGNMENT-1);
+}
+
+static int IsLegalGeometry(int startCipherBlkNo, int bitLen, int duBitsize)
+{
+ int duBlocks = (duBitsize+IPP_AES_BLOCK_BITSIZE-1)/IPP_AES_BLOCK_BITSIZE;
+ int legalBlk = (0<=startCipherBlkNo && startCipherBlkNo<duBlocks) && ((startCipherBlkNo*IPP_AES_BLOCK_BITSIZE+bitLen)<=duBitsize);
+ int legalLen = 0;
+ if(0 == duBitsize%IPP_AES_BLOCK_BITSIZE) {
+ legalLen = (0 == bitLen%IPP_AES_BLOCK_BITSIZE);
+ }
+ else
+ if(bitLen%IPP_AES_BLOCK_BITSIZE)
+ legalLen = (startCipherBlkNo*IPP_AES_BLOCK_BITSIZE+bitLen == duBitsize);
+ return legalBlk && legalLen;
+}
+
+
+#endif /* _NEW_XTS_API_ */
+
+#endif /* _PCP_AES_XTS_H */
diff --git a/ext/ipp/sources/ippcp/pcpaesmxtsstuff.h b/ext/ipp/sources/ippcp/pcpaesmxtsstuff.h
new file mode 100644
index 0000000..bc5f726
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpaesmxtsstuff.h
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// AES-XTS Internal Functions
+//
+//
+*/
+
+#if !defined(_PCP_AES_XTS_STUFF_H)
+#define _PCP_AES_XTS_STUFF_H
+
+#include "owncp.h"
+#include "pcpaesm.h"
+
+/*
+ multiplication by primirive element alpha (==2)
+ over P=x^128 +x^7 +x^2 +x +1
+
+ LE version
+*/
+
+#if (_IPP_ARCH ==_IPP_ARCH_EM64T)
+#pragma message ("_IPP_ARCH_EM64T")
+#define GF_MASK (0x8000000000000000)
+#define GF_POLY (0x0000000000000087)
+
+__INLINE void gf_mul_by_primitive(void* x)
+{
+#if 0
+ Ipp64u* x64 = (Ipp64u*)x;
+ Ipp64u xorL = ((Ipp64s)x64[1] >> (BITSIZE(Ipp64u)-1)) & GF_POLY;
+ x64[1] = (x64[1]+x64[1]) | (x64[0] >>(BITSIZE(Ipp64u)-1));
+ x64[0] = (x64[0]+x64[0]) ^ xorL;
+#endif
+ Ipp64u* x64 = (Ipp64u*)x;
+ Ipp64u xorL = (0>(Ipp64s)x64[1])? GF_POLY : 0;
+ Ipp64u addH = (0>(Ipp64s)x64[0])? 1 : 0;
+ x64[0] = (x64[0]+x64[0]) ^ xorL;
+ x64[1] = (x64[1]+x64[1]) + addH;
+}
+
+//#elif (_IPP_ARCH ==_IPP_ARCH_IA32)
+#else
+#pragma message ("_IPP_ARCH_IA32")
+#define GF_MASK (0x80000000)
+#define GF_POLY (0x00000087)
+
+__INLINE void gf_mul_by_primitive(void* x)
+{
+ Ipp32u* x32 = (Ipp32u*)x;
+ Ipp32u xorL = ((Ipp32s)(x32[3]&GF_MASK) >> (BITSIZE(Ipp32u)-1)) & GF_POLY;
+ x32[3] = (x32[3]<<1) | (x32[2] >>(BITSIZE(Ipp32u)-1));
+ x32[2] = (x32[2]<<1) | (x32[1] >>(BITSIZE(Ipp32u)-1));
+ x32[1] = (x32[1]<<1) | (x32[0] >>(BITSIZE(Ipp32u)-1));
+ x32[0] = (x32[0]<<1) ^ xorL;
+}
+#endif
+
+/*
+ the following are especially for multi-block processing
+*/
+static void cpXTSwhitening(Ipp8u* buffer, int nblk, Ipp8u* ptwk)
+{
+ Ipp64u* pbuf64 = (Ipp64u*)buffer;
+ Ipp64u* ptwk64 = (Ipp64u*)ptwk;
+
+ pbuf64[0] = ptwk64[0];
+ pbuf64[1] = ptwk64[1];
+
+ for(nblk--, pbuf64+=2; nblk>0; nblk--, pbuf64+=2) {
+ gf_mul_by_primitive(ptwk64);
+ pbuf64[0] = ptwk64[0];
+ pbuf64[1] = ptwk64[1];
+ }
+ gf_mul_by_primitive(ptwk64);
+}
+
+static void cpXTSxor16(Ipp8u* pDst, const Ipp8u* pSrc1, const Ipp8u* pSrc2, int nblk)
+{
+ Ipp64u* pdst64 = (Ipp64u*)pDst;
+ const Ipp64u* ps1_64 = (const Ipp64u*)pSrc1;
+ const Ipp64u* ps2_64 = (const Ipp64u*)pSrc2;
+ for(; nblk>0; nblk--, pdst64+=2, ps1_64+=2, ps2_64+=2) {
+ pdst64[0] = ps1_64[0] ^ ps2_64[0];
+ pdst64[1] = ps1_64[1] ^ ps2_64[1];
+ }
+}
+///////////////////////////////
+
+
+#endif /* _PCP_AES_XTS_STUFF_H */
diff --git a/ext/ipp/sources/ippcp/pcparcfour.h b/ext/ipp/sources/ippcp/pcparcfour.h
new file mode 100644
index 0000000..118a8ac
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcparcfour.h
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2005-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RC4 Internal Definitions and Function Prototypes
+//
+*/
+
+#if !defined(_ARCFOUR_H)
+#define _ARCFOUR_H
+#define _ARCFOUR_H
+
+#if ((_IPP==_IPP_W7) || (_IPP==_IPP_T7))
+ #define rc4word Ipp8u
+ #pragma message("Sbox: byte")
+
+
+#elif ((_IPP>=_IPP_V8) || (_IPP32E>=_IPP32E_M7))
+ #define rc4word Ipp32u
+ #pragma message("Sbox: dword")
+
+#else
+ #define rc4word Ipp8u
+ #pragma message("Sbox: byte")
+#endif
+
+/*
+// ARCFOUR context
+*/
+struct _cpARCfour {
+ IppCtxId idCtx; /* RC4 identifier */
+
+ Ipp32u cntX; /* algorithm's counter x */
+ Ipp32u cntY; /* algorithm's counter y */
+ rc4word Sbox[256]; /* current state block.*/
+ Ipp8u Sbox0[256]; /* initial state block */
+};
+
+/* alignment */
+#define RC4_ALIGNMENT ((int)(sizeof(Ipp32u)))
+
+/*
+// Useful macros
+*/
+#define RC4_ID(ctx) ((ctx)->idCtx)
+#define RC4_CNTX(ctx) ((ctx)->cntX)
+#define RC4_CNTY(ctx) ((ctx)->cntY)
+#define RC4_SBOX(ctx) ((ctx)->Sbox)
+#define RC4_SBOX0(ctx) ((ctx)->Sbox0)
+
+#define RC4_VALID_ID(ctx) (RC4_ID((ctx))==idCtxARCFOUR)
+
+/*
+// internal functions
+*/
+#define ARCFourProcessData OWNAPI(ARCFourProcessData)
+ void ARCFourProcessData(const Ipp8u *pSrc, Ipp8u *pDst, int length, IppsARCFourState *pCtx);
+
+#endif /* _ARCFOUR_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpbn.h b/ext/ipp/sources/ippcp/pcpbn.h
index 98c7639..5d8c498 100644
--- a/ext/ipp/sources/ippcp/src/pcpbn.h
+++ b/ext/ipp/sources/ippcp/pcpbn.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 2002-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Intel(R) Integrated Performance Primitives
diff --git a/ext/ipp/sources/ippcp/pcpbn_pack.c b/ext/ipp/sources/ippcp/pcpbn_pack.c
new file mode 100644
index 0000000..15038ec
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbn_pack.c
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpPackBigNumCtx()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: cpPackBigNumCtx
+//
+// Purpose: Serialize bigNum context
+//
+// Parameters:
+// pBN BigNum
+// pBuffer buffer
+*F*/
+void cpPackBigNumCtx(const IppsBigNumState* pBN, Ipp8u* pBuffer)
+{
+ IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT));
+ CopyBlock(pBN, pAlignedBuffer, sizeof(IppsBigNumState));
+ BN_NUMBER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_NUMBER(pBN))-IPP_UINT_PTR(pBN));
+ BN_BUFFER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_BUFFER(pBN))-IPP_UINT_PTR(pBN));
+ CopyBlock(BN_NUMBER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
+ CopyBlock(BN_BUFFER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
+}
diff --git a/ext/ipp/sources/ippcp/pcpbn_unpack.c b/ext/ipp/sources/ippcp/pcpbn_unpack.c
new file mode 100644
index 0000000..e32e6c3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbn_unpack.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpUnpackBigNumCtx()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: cpUnpackBigNumCtx
+//
+// Purpose: Deserialize bigNum context
+//
+// Parameters:
+// pBN BigNum
+// pBuffer buffer
+*F*/
+
+
+void cpUnpackBigNumCtx(const Ipp8u* pBuffer, IppsBigNumState* pBN)
+{
+ IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT));
+ CopyBlock(pBuffer, pBN, sizeof(IppsBigNumState));
+ BN_NUMBER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)));
+ BN_BUFFER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)));
+ CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_NUMBER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
+ CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_BUFFER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
+}
diff --git a/ext/ipp/sources/ippcp/pcpbn_val1.c b/ext/ipp/sources/ippcp/pcpbn_val1.c
new file mode 100644
index 0000000..7769a45
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbn_val1.c
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpBN_OneRef()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: cpBN_OneRef
+//
+// Purpose: BN(1) and reference
+//
+// Return:
+// BigNum = 1
+*F*/
+
+/* BN(1) and reference */
+IppsBigNumState* cpBN_OneRef(void)
+{
+ static IppsBigNumStateChunk cpChunk_BN1 = {
+ {
+ idCtxBigNum,
+ ippBigNumPOS,
+ 1,1,
+ &cpChunk_BN1.value,&cpChunk_BN1.temporary
+ },
+ 1,0
+ };
+ return &cpChunk_BN1.bn;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbn_val2.c b/ext/ipp/sources/ippcp/pcpbn_val2.c
new file mode 100644
index 0000000..6baf5b8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbn_val2.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpBN_TwoRef()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: cpBN_TwoRef
+//
+// Purpose: BN(2) and reference
+//
+// Return:
+// BigNum = 2
+*F*/
+
+IppsBigNumState* cpBN_TwoRef(void)
+{
+ static IppsBigNumStateChunk cpChunk_BN2 = {
+ {
+ idCtxBigNum,
+ ippBigNumPOS,
+ 1,1,
+ &cpChunk_BN2.value,&cpChunk_BN2.temporary
+ },
+ 2,0
+ };
+ return &cpChunk_BN2.bn;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbn_val3.c b/ext/ipp/sources/ippcp/pcpbn_val3.c
new file mode 100644
index 0000000..c474eb0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbn_val3.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpBN_ThreeRef()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: cpBN_ThreeRef
+//
+// Purpose: BN(3) and reference
+//
+// Return:
+// BigNum = 3
+*F*/
+
+IppsBigNumState* cpBN_ThreeRef(void)
+{
+ static IppsBigNumStateChunk cpChunk_BN3 = {
+ {
+ idCtxBigNum,
+ ippBigNumPOS,
+ 1,1,
+ &cpChunk_BN3.value,&cpChunk_BN3.temporary
+ },
+ 3,0
+ };
+ return &cpChunk_BN3.bn;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithadd.c b/ext/ipp/sources/ippcp/pcpbnarithadd.c
new file mode 100644
index 0000000..53e5f0e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithadd.c
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsAdd_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsAdd_BN
+//
+// Purpose: Add BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pR)
+// ippStsOutOfRangeErr pR can not hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum A
+// pB source BigNum B
+// pR resultant BigNum
+//
+*F*/
+IPPFUN(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ {
+ cpSize nsA = BN_SIZE(pA);
+ cpSize nsB = BN_SIZE(pB);
+ cpSize nsR = BN_ROOM(pR);
+ IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+
+ IppsBigNumSGN sgnA = BN_SIGN(pA);
+ IppsBigNumSGN sgnB = BN_SIGN(pB);
+ BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
+ BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
+
+ BNU_CHUNK_T carry;
+
+ if(sgnA==sgnB) {
+ if(nsA < nsB) {
+ SWAP(nsA, nsB);
+ SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
+ }
+
+ carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
+ if(nsA>nsB)
+ carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
+ if(carry) {
+ if(nsR>nsA)
+ pDataR[nsA++] = carry;
+ else
+ IPP_ERROR_RET(ippStsOutOfRangeErr);
+ }
+ BN_SIGN(pR) = sgnA;
+ }
+
+ else {
+ int cmpRes = cpCmp_BNU(pDataA, nsA, pDataB, nsB);
+
+ if(0==cmpRes) {
+ pDataR[0] = 0;
+ BN_SIZE(pR) = 1;
+ BN_SIGN(pR) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+
+ if(0>cmpRes) {
+ SWAP(nsA, nsB);
+ SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
+ }
+
+ carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
+ if(nsA>nsB)
+ cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
+
+ BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
+ }
+
+ FIX_BNU(pDataR, nsA);
+ BN_SIZE(pR) = nsA;
+
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithcmp.c b/ext/ipp/sources/ippcp/pcpbnarithcmp.c
new file mode 100644
index 0000000..695bc26
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithcmp.c
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsCmp_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsCmp_BN
+//
+// Purpose: Compare two BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pResult == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA BigNum ctx
+// pB BigNum ctx
+// pResult result of comparison
+//
+*F*/
+IPPFUN(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u *pResult))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pResult);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+
+ {
+ int res;
+ if(BN_SIGN(pA)==BN_SIGN(pB)) {
+ res = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB));
+ if(ippBigNumNEG==BN_SIGN(pA))
+ res = -res;
+ }
+ else
+ res = (ippBigNumPOS==BN_SIGN(pA))? 1 :-1;
+
+ *pResult = (1==res)? IPP_IS_GT : (-1==res)? IPP_IS_LT : IPP_IS_EQ;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithcmpz.c b/ext/ipp/sources/ippcp/pcpbnarithcmpz.c
new file mode 100644
index 0000000..f182b6a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithcmpz.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsCmpZero_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsCmpZero_BN
+//
+// Purpose: Compare BigNum value with zero.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// pResult == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBN BigNum ctx
+// pResult result of comparison
+//
+*F*/
+IPPFUN(IppStatus, ippsCmpZero_BN, (const IppsBigNumState* pBN, Ipp32u* pResult))
+{
+ IPP_BAD_PTR2_RET(pBN, pResult);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ if(BN_SIZE(pBN)==1 && BN_NUMBER(pBN)[0]==0)
+ *pResult = IS_ZERO;
+ else if (BN_SIGN(pBN)==ippBigNumPOS)
+ *pResult = GREATER_THAN_ZERO;
+ else if (BN_SIGN(pBN)==ippBigNumNEG)
+ *pResult = LESS_THAN_ZERO;
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithdiv.c b/ext/ipp/sources/ippcp/pcpbnarithdiv.c
new file mode 100644
index 0000000..a76f57b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithdiv.c
@@ -0,0 +1,125 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsDiv_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsDiv_BN
+//
+// Purpose: Divide BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pQ == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pQ)
+// !BN_VALID_ID(pR)
+// ippStsDivByZeroErr BN_SIZE(pB) == 1 && BN_NUMBER(pB)[0] == 0
+// ippStsOutOfRangeErr pQ and/or pR can not hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pQ quotient BigNum
+// pR reminder BigNum
+//
+// A = Q*B + R, 0 <= val(R) < val(B), sgn(A)==sgn(R)
+//
+*F*/
+IPPFUN(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pQ, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ pQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pQ, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pQ), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_SIZE(pB)== 1 && BN_NUMBER(pB)[0]==0, ippStsDivByZeroErr);
+
+ IPP_BADARG_RET(BN_ROOM(pR)<BN_SIZE(pB), ippStsOutOfRangeErr);
+ IPP_BADARG_RET((int)BN_ROOM(pQ)<(int)(BN_SIZE(pA)-BN_SIZE(pB)), ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* pDataA = BN_BUFFER(pA);
+ cpSize nsA = BN_SIZE(pA);
+ BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
+ cpSize nsB = BN_SIZE(pB);
+ BNU_CHUNK_T* pDataQ = BN_NUMBER(pQ);
+ cpSize nsQ;
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+ cpSize nsR;
+
+ COPY_BNU(pDataA, BN_NUMBER(pA), nsA);
+ nsR = cpDiv_BNU(pDataQ, &nsQ, pDataA, nsA, pDataB, nsB);
+ COPY_BNU(pDataR, pDataA, nsR);
+
+ BN_SIGN(pQ) = BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG;
+ BN_SIZE(pQ) = nsQ;
+ if(nsQ==1 && pDataQ[0]==0) BN_SIGN(pQ) = ippBigNumPOS;
+
+ BN_SIGN(pR) = BN_SIGN(pA);
+ BN_SIZE(pR) = nsR;
+ if(nsR==1 && pDataR[0]==0) BN_SIGN(pR) = ippBigNumPOS;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithgcd.c b/ext/ipp/sources/ippcp/pcpbnarithgcd.c
new file mode 100644
index 0000000..f16f30f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithgcd.c
@@ -0,0 +1,298 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsGcd_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGcd_BN
+//
+// Purpose: compute GCD value.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pGCD == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pGCD)
+// ippStsBadArgErr A==B==0
+// ippStsOutOfRangeErr pGCD can not hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pGCD GCD value
+//
+*F*/
+IPPFUN(IppStatus, ippsGcd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pGCD))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pGCD);
+
+ pA = (IppsBigNumState*)(IPP_ALIGNED_PTR(pA, BN_ALIGNMENT));
+ pB = (IppsBigNumState*)(IPP_ALIGNED_PTR(pB, BN_ALIGNMENT));
+ pGCD = (IppsBigNumState*)(IPP_ALIGNED_PTR(pGCD, BN_ALIGNMENT));
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pGCD), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_ROOM(pGCD) < IPP_MIN(BN_SIZE(pA), BN_SIZE(pB)), ippStsOutOfRangeErr);
+
+ {
+ IppsBigNumState* x = pA;
+ IppsBigNumState* y = pB;
+ IppsBigNumState* g = pGCD;
+
+ int aIsZero = BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0;
+ int bIsZero = BN_SIZE(pB)==1 && BN_NUMBER(pB)[0]==0;
+
+ if(aIsZero && bIsZero)
+ return ippStsBadArgErr;
+ if(aIsZero && !bIsZero) {
+ COPY_BNU(BN_NUMBER(g), BN_NUMBER(pB), BN_SIZE(pB));
+ BN_SIZE(g) = BN_SIZE(pB);
+ BN_SIGN(g) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+ if(bIsZero && !aIsZero) {
+ COPY_BNU(BN_NUMBER(g), BN_NUMBER(pA), BN_SIZE(pA));
+ BN_SIZE(g) = BN_SIZE(pA);
+ BN_SIGN(g) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+
+ /*
+ // Lehmer's algorithm requres that first number must be greater than second
+ // x is the first, y is the second
+ */
+ {
+ int cmpRes = cpCmp_BNU(BN_NUMBER(x), BN_SIZE(x), BN_NUMBER(y), BN_SIZE(y));
+ if(0>cmpRes)
+ SWAP_PTR(IppsBigNumState, x, y);
+ if(0==cmpRes) {
+ COPY_BNU(BN_NUMBER(g), BN_NUMBER(x), BN_SIZE(x));
+ BN_SIGN(g) = ippBigNumPOS;
+ BN_SIZE(g) = BN_SIZE(x);
+ return ippStsNoErr;
+ }
+ if(BN_SIZE(x)==1) {
+ BNU_CHUNK_T gcd = cpGcd_BNU(BN_NUMBER(x)[0], BN_NUMBER(y)[0]);
+ BN_NUMBER(g)[0] = gcd;
+ BN_SIZE(g) = 1;
+ return ippStsNoErr;
+ }
+ }
+
+ {
+ Ipp32u* xBuffer = (Ipp32u*)BN_BUFFER(x);
+ Ipp32u* yBuffer = (Ipp32u*)BN_BUFFER(y);
+ Ipp32u* gBuffer = (Ipp32u*)BN_BUFFER(g);
+ Ipp32u* xData = (Ipp32u*)BN_NUMBER(x);
+ Ipp32u* yData = (Ipp32u*)BN_NUMBER(y);
+ Ipp32u* gData = (Ipp32u*)BN_NUMBER(g);
+ cpSize nsXmax = BN_ROOM(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+ cpSize nsYmax = BN_ROOM(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+ cpSize nsGmax = BN_ROOM(g)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+ cpSize nsX = BN_SIZE(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+ cpSize nsY = BN_SIZE(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+
+ Ipp32u* T;
+ Ipp32u* u;
+
+ FIX_BNU(xData, nsX);
+ FIX_BNU(yData, nsY);
+
+ /* init buffers */
+ ZEXPAND_COPY_BNU(xBuffer, nsXmax, xData, nsX);
+ ZEXPAND_COPY_BNU(yBuffer, nsYmax, yData, nsY);
+
+ T = gBuffer;
+ u = gData;
+ ZEXPAND_BNU(T, 0, nsGmax);
+ ZEXPAND_BNU(u, 0, nsGmax);
+
+ while(nsX > (cpSize)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
+ /* xx and yy is the high-order digits of x and y (yy could be 0) */
+
+ Ipp64u xx = (Ipp64u)(xBuffer[nsX-1]);
+ Ipp64u yy = (nsY < nsX)? 0 : (Ipp64u)(yBuffer[nsY-1]);
+
+ Ipp64s AA = 1;
+ Ipp64s BB = 0;
+ Ipp64s CC = 0;
+ Ipp64s DD = 1;
+ Ipp64s t;
+
+ while((yy+CC)!=0 && (yy+DD)!=0) {
+ Ipp64u q = ( xx + AA ) / ( yy + CC );
+ Ipp64u q1 = ( xx + BB ) / ( yy + DD );
+ if(q!=q1)
+ break;
+ t = AA - q*CC;
+ AA = CC;
+ CC = t;
+ t = BB - q*DD;
+ BB = DD;
+ DD = t;
+ t = xx - q*yy;
+ xx = yy;
+ yy = t;
+ }
+
+ if(BB == 0) {
+ /* T = x mod y */
+ cpSize nsT = cpMod_BNU32(xBuffer, nsX, yBuffer, nsY);
+ ZEXPAND_BNU(T, 0, nsGmax);
+ COPY_BNU(T, xBuffer, nsT);
+ /* a = b; b = T; */
+ ZEXPAND_BNU(xBuffer, 0, nsXmax);
+ COPY_BNU(xBuffer, yBuffer, nsY);
+ ZEXPAND_BNU(yBuffer, 0, nsYmax);
+ COPY_BNU(yBuffer, T, nsY);
+ }
+
+ else {
+ Ipp32u carry;
+ /*
+ // T = AA*x + BB*y;
+ // u = CC*x + DD*y;
+ // b = u; a = T;
+ */
+ if((AA <= 0)&&(BB>=0)) {
+ Ipp32u a1 = (Ipp32u)(-AA);
+ carry = cpMulDgt_BNU32(T, yBuffer, nsY, (Ipp32u)BB);
+ carry = cpMulDgt_BNU32(u, xBuffer, nsY, a1);
+ /* T = BB*y - AA*x; */
+ carry = cpSub_BNU32(T, T, u, nsY);
+ }
+ else {
+ if((AA >= 0)&&(BB<=0)) {
+ Ipp32u b1 = (Ipp32u)(-BB);
+ carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
+ carry = cpMulDgt_BNU32(u, yBuffer, nsY, b1);
+ /* T = AA*x - BB*y; */
+ carry = cpSub_BNU32(T, T, u, nsY);
+ }
+ else {
+ /*AA*BB>=0 */
+ carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
+ carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)BB);
+ /* T = AA*x + BB*y; */
+ carry = cpAdd_BNU32(T, T, u, nsY);
+ }
+ }
+
+ /* Now T is reserved. We use only u for intermediate results. */
+ if((CC <= 0)&&(DD>=0)){
+ Ipp32u c1 = (Ipp32u)(-CC);
+ /* u = x*CC; x = u; */
+ carry = cpMulDgt_BNU32(u, xBuffer, nsY, c1);
+ COPY_BNU(xBuffer, u, nsY);
+ /* u = y*DD; */
+ carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
+ /* u = DD*y - CC*x; */
+ carry = cpSub_BNU32(u, u, xBuffer, nsY);
+ }
+ else {
+ if((CC >= 0)&&(DD<=0)){
+ Ipp32u d1 = (Ipp32u)(-DD);
+ /* u = y*DD; y = u */
+ carry = cpMulDgt_BNU32(u, yBuffer, nsY, d1);
+ COPY_BNU(yBuffer, u, nsY);
+ /* u = CC*x; */
+ carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
+ /* u = CC*x - DD*y; */
+ carry = cpSub_BNU32(u, u, yBuffer, nsY);
+ }
+ else {
+ /*CC*DD>=0 */
+ /* y = y*DD */
+ carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
+ COPY_BNU(yBuffer, u, nsY);
+ /* u = x*CC */
+ carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
+ /* u = x*CC + y*DD */
+ carry = cpAdd_BNU32(u, u, yBuffer, nsY);
+ }
+ }
+
+ /* y = u; x = T; */
+ COPY_BNU(yBuffer, u, nsY);
+ COPY_BNU(xBuffer, T, nsY);
+ }
+
+ FIX_BNU(xBuffer, nsX);
+ FIX_BNU(yBuffer, nsY);
+
+ if (nsY > nsX) {
+ SWAP_PTR(IppsBigNumState, x, y);
+ SWAP(nsX, nsY);
+ }
+
+ if (nsY==1 && yBuffer[nsY-1]==0) {
+ /* End evaluation */
+ ZEXPAND_BNU(gData, 0, nsGmax);
+ COPY_BNU(gData, xBuffer, nsX);
+ BN_SIZE(g) = INTERNAL_BNU_LENGTH(nsX);
+ BN_SIGN(g) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+ }
+
+ BN_NUMBER(g)[0] = cpGcd_BNU(((BNU_CHUNK_T*)xBuffer)[0], ((BNU_CHUNK_T*)yBuffer)[0]);
+ BN_SIZE(g) = 1;
+ BN_SIGN(g) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithmac.c b/ext/ipp/sources/ippcp/pcpbnarithmac.c
new file mode 100644
index 0000000..32a2647
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithmac.c
@@ -0,0 +1,151 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMAC_BN_I()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsMAC_BN_I
+//
+// Purpose: Multiply and Accumulate BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pR)
+// ippStsOutOfRangeErr pR can not fit result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pR resultant BigNum
+//
+*F*/
+IPPFUN(IppStatus, ippsMAC_BN_I, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ {
+ BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
+ BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
+
+ cpSize nsA = BN_SIZE(pA);
+ cpSize nsB = BN_SIZE(pB);
+
+ cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA);
+ cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB);
+ /* size of temporary pruduct */
+ cpSize nsP = BITS_BNU_CHUNK(bitSizeA+bitSizeB);
+
+ /* test if multiplicant/multiplier is zero */
+ if(!bitSizeA || !bitSizeB) return ippStsNoErr;
+ /* test if product can't fit to the result */
+ IPP_BADARG_RET(BN_ROOM(pR)<nsP, ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+ IppsBigNumSGN sgnR = BN_SIGN(pR);
+ cpSize nsR = BN_SIZE(pR);
+ cpSize room = BN_ROOM(pR);
+
+ /* temporary product */
+ BNU_CHUNK_T* pDataP = BN_BUFFER(pR);
+ IppsBigNumSGN sgnP = BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG;
+
+ /* clear the rest of R data buffer */
+ ZEXPAND_BNU(pDataR, nsR, room);
+
+ /* temporary product */
+ if(pA==pB)
+ cpSqr_BNU_school(pDataP, pDataA, nsA);
+ else
+ cpMul_BNU_school(pDataP, pDataA, nsA, pDataB, nsB);
+ /* clear the rest of rpoduct */
+ ZEXPAND_BNU(pDataP, nsP, room);
+
+ if(sgnR==sgnP) {
+ BNU_CHUNK_T carry = cpAdd_BNU(pDataR, pDataR, pDataP, room);
+ if(carry) {
+ BN_SIZE(pR) = room;
+ IPP_ERROR_RET(ippStsOutOfRangeErr);
+ }
+ }
+
+ else {
+ BNU_CHUNK_T* pTmp = pDataR;
+ int cmpRes = cpCmp_BNU(pDataR, room, pDataP, room);
+ if(0>cmpRes) {
+ SWAP_PTR(BNU_CHUNK_T, pTmp, pDataP);
+ }
+ cpSub_BNU(pDataR, pTmp, pDataP, room);
+
+ BN_SIGN(pR) = cmpRes>0? sgnR : INVERSE_SIGN(sgnR);
+ }
+
+ FIX_BNU(pDataR, room);
+ BN_SIZE(pR) = room;
+
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithminv.c b/ext/ipp/sources/ippcp/pcpbnarithminv.c
new file mode 100644
index 0000000..7405c42
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithminv.c
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsModInv_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsModInv_BN
+//
+// Purpose: Multiplicative Inversion BigNum.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pM == NULL
+// pInv == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pM)
+// !BN_VALID_ID(pInv)
+// ippStsBadArgErr A<=0
+// ippStsBadModulusErr M<=0
+// ippStsScaleRangeErr A>=M
+// ippStsOutOfRangeErr pInv can not hold result
+// ippStsNoErr no errors
+// ippStsBadModulusErr inversion not found
+//
+// Parameters:
+// pA source (value) BigNum
+// pM source (modulus) BigNum
+// pInv result BigNum
+//
+*F*/
+IPPFUN(IppStatus, ippsModInv_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pInv) )
+{
+ IPP_BAD_PTR3_RET(pA, pM, pInv);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr);
+ pInv = (IppsBigNumState*)( IPP_ALIGNED_PTR(pInv, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pInv), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_ROOM(pInv) < BN_SIZE(pM), ippStsOutOfRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pA) || (BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0), ippStsBadArgErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pM) || (BN_SIZE(pM)==1 && BN_NUMBER(pM)[0]==0), ippStsBadModulusErr);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pM), BN_SIZE(pM)) >= 0, ippStsScaleRangeErr);
+
+ {
+ cpSize nsR = cpModInv_BNU(BN_NUMBER(pInv),
+ BN_NUMBER(pA), BN_SIZE(pA),
+ BN_NUMBER(pM), BN_SIZE(pM),
+ BN_BUFFER(pInv), BN_BUFFER(pA), BN_BUFFER(pM));
+ if(nsR) {
+ BN_SIGN(pInv) = ippBigNumPOS;
+ BN_SIZE(pInv) = nsR;
+ return ippStsNoErr;
+ }
+ else
+ return ippStsBadModulusErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithmod.c b/ext/ipp/sources/ippcp/pcpbnarithmod.c
new file mode 100644
index 0000000..d78c121
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithmod.c
@@ -0,0 +1,127 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMod_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsMod_BN
+//
+// Purpose: reduction BigNum.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pM == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pM)
+// !BN_VALID_ID(pR)
+// ippStsOutOfRangeErr pR can not hold result
+// ippStsBadModulusErr modulus IppsBigNumState* pM
+// is not a positive integer
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pR reminder BigNum
+//
+// A = Q*M + R, 0 <= R < B
+//
+*F*/
+IPPFUN(IppStatus, ippsMod_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pA, pM, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_NEGATIVE(pM), ippStsBadModulusErr);
+ IPP_BADARG_RET(BN_SIZE(pM)== 1 && BN_NUMBER(pM)[0]==0, ippStsBadModulusErr);
+
+ IPP_BADARG_RET(BN_ROOM(pR)<BN_SIZE(pM), ippStsOutOfRangeErr);
+
+ if(cpEqu_BNU_CHUNK(BN_NUMBER(pA), BN_SIZE(pA), 0)) {
+ BN_SIGN(pR) = ippBigNumPOS;
+ BN_SIZE(pR) = 1;
+ BN_NUMBER(pR)[0] = 0;
+ }
+
+ else {
+ BNU_CHUNK_T* pDataM = BN_NUMBER(pM);
+ cpSize nsM = BN_SIZE(pM);
+ BNU_CHUNK_T* pBuffA = BN_BUFFER(pA);
+ cpSize nsA = BN_SIZE(pA);
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+ cpSize nsR;
+
+ COPY_BNU(pBuffA, BN_NUMBER(pA), nsA);
+ nsR = cpMod_BNU(pBuffA, nsA, pDataM, nsM);
+
+ COPY_BNU(pDataR, pBuffA, nsR);
+ BN_SIZE(pR) = nsR;
+ BN_SIGN(pR) = ippBigNumPOS;
+
+ if(BN_NEGATIVE(pA) && !(nsR==1 && pDataR[0]==0)) {
+ ZEXPAND_BNU(pDataR, nsR, nsM);
+ cpSub_BNU(pDataR, pDataM, pDataR, nsM);
+ FIX_BNU(pDataR, nsM);
+ BN_SIZE(pR) = nsM;
+ }
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithmul.c b/ext/ipp/sources/ippcp/pcpbnarithmul.c
new file mode 100644
index 0000000..25d4ba5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithmul.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMul_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsMul_BN
+//
+// Purpose: Multiply BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pR)
+// ippStsOutOfRangeErr pR can not hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pR resultant BigNum
+//
+*F*/
+IPPFUN(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ {
+ BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
+ BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+
+ cpSize nsA = BN_SIZE(pA);
+ cpSize nsB = BN_SIZE(pB);
+ cpSize nsR = BN_ROOM(pR);
+
+ cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA);
+ cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB);
+
+ /* test if multiplicant/multiplier is zero */
+ if(!bitSizeA || !bitSizeB) {
+ BN_SIZE(pR) = 1;
+ BN_SIGN(pR) = IppsBigNumPOS;
+ pDataR[0] = 0;
+ return ippStsNoErr;
+ }
+
+ /* test if even low estimation of product A*B exceeded */
+ IPP_BADARG_RET(nsR*BNU_CHUNK_BITS < (bitSizeA+bitSizeB-1), ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* aData = pDataA;
+ BNU_CHUNK_T* bData = pDataB;
+
+ if(pA == pR) {
+ aData = BN_BUFFER(pR);
+ COPY_BNU(aData, pDataA, nsA);
+ }
+ if((pB == pR) && (pA != pB)) {
+ bData = BN_BUFFER(pR);
+ COPY_BNU(bData, pDataB, nsB);
+ }
+
+ /* clear result */
+ ZEXPAND_BNU(pDataR, 0, nsR+1);
+
+ if(pA==pB)
+ cpSqr_BNU_school(pDataR, aData, nsA);
+ else
+ cpMul_BNU_school(pDataR, aData, nsA, bData, nsB);
+
+ nsR = (bitSizeA + bitSizeB + BNU_CHUNK_BITS - 1) /BNU_CHUNK_BITS;
+ FIX_BNU(pDataR, nsR);
+ IPP_BADARG_RET(nsR>BN_ROOM(pR), ippStsOutOfRangeErr);
+
+ BN_SIZE(pR) = nsR;
+ BN_SIGN(pR) = (BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG);
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnarithsub.c b/ext/ipp/sources/ippcp/pcpbnarithsub.c
new file mode 100644
index 0000000..ad59de3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnarithsub.c
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsSub_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsSub_BN
+//
+// Purpose: Subtract BigNums.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pB == NULL
+// pR == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pA)
+// !BN_VALID_ID(pB)
+// !BN_VALID_ID(pR)
+// ippStsOutOfRangeErr pR can not hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pR resultant BigNum
+//
+*F*/
+IPPFUN(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pA, pB, pR);
+
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ {
+ cpSize nsA = BN_SIZE(pA);
+ cpSize nsB = BN_SIZE(pB);
+ cpSize nsR = BN_ROOM(pR);
+ IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+
+ IppsBigNumSGN sgnA = BN_SIGN(pA);
+ IppsBigNumSGN sgnB = BN_SIGN(pB);
+ BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
+ BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
+
+ BNU_CHUNK_T carry;
+
+ if(sgnA!=sgnB) {
+ if(nsA < nsB) {
+ SWAP(nsA, nsB);
+ SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
+ }
+
+ carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
+ if(nsA>nsB)
+ carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
+ if(carry) {
+ if(nsR > nsA)
+ pDataR[nsA++] = carry;
+ else
+ IPP_ERROR_RET(ippStsOutOfRangeErr);
+ }
+ BN_SIGN(pR) = sgnA;
+ }
+
+ else {
+ int cmpRes= cpCmp_BNU(pDataA, nsA, pDataB, nsB);
+
+ if(0==cmpRes) {
+ ZEXPAND_BNU(pDataR,0, nsR);
+ BN_SIZE(pR) = 1;
+ BN_SIGN(pR) = ippBigNumPOS;
+ return ippStsNoErr;
+ }
+
+ if(0>cmpRes) {
+ SWAP(nsA, nsB);
+ SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
+ }
+
+ carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
+ if(nsA>nsB)
+ cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
+
+ BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
+ }
+
+ FIX_BNU(pDataR, nsA);
+ BN_SIZE(pR) = nsA;
+
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetext.c b/ext/ipp/sources/ippcp/pcpbngetext.c
new file mode 100644
index 0000000..ebdc047
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetext.c
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsExtGet_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsExtGet_BN
+//
+// Purpose: Extracts the specified combination of the sign, data
+// length, and value characteristics of the integer big
+// number from the input structure.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSgn pointer to the sign
+// pBitSize pointer to the data size (in bits)
+// pData pointer to the data buffer
+// pBN BigNum ctx
+//
+*F*/
+
+IPPFUN(IppStatus, ippsExtGet_BN, (IppsBigNumSGN* pSgn, int* pBitSize, Ipp32u* pData,
+ const IppsBigNumState* pBN))
+{
+ IPP_BAD_PTR1_RET(pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ {
+ cpSize bitSize = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN));
+ if(0==bitSize)
+ bitSize = 1;
+ if(pData)
+ COPY_BNU(pData, (Ipp32u*)BN_NUMBER(pBN), BITS2WORD32_SIZE(bitSize));
+ if(pSgn)
+ *pSgn = BN_SIGN(pBN);
+ if(pBitSize)
+ *pBitSize = bitSize;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetlen.c b/ext/ipp/sources/ippcp/pcpbngetlen.c
new file mode 100644
index 0000000..59079cf
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetlen.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsGetSize_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGetSize_BN
+//
+// Purpose: Returns BigNum room.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// pSize == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBN BigNum ctx
+// pSize max BigNum length (in Ipp32u chunks)
+//
+*F*/
+IPPFUN(IppStatus, ippsGetSize_BN, (const IppsBigNumState* pBN, int* pSize))
+{
+ IPP_BAD_PTR2_RET(pBN, pSize);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ *pSize = BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetoctstr.c b/ext/ipp/sources/ippcp/pcpbngetoctstr.c
new file mode 100644
index 0000000..766f8aa
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetoctstr.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Big Number Operations
+//
+// Contents:
+// ippsGetOctString_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+
+
+/*F*
+// Name: ippsGetOctString_BN
+//
+// Purpose: Convert BN value into the octet string.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pOctStr
+// NULL == pBN
+//
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+//
+// ippStsRangeErr BN <0
+//
+// ippStsLengthErr strLen is enough for keep BN value
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBN pointer to the source BN
+// pOctStr pointer to the target octet string
+// strLen octet string length
+*F*/
+IPPFUN(IppStatus, ippsGetOctString_BN,(Ipp8u* pOctStr, int strLen,
+ const IppsBigNumState* pBN))
+{
+ IPP_BAD_PTR2_RET(pOctStr, pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pBN), ippStsRangeErr);
+ IPP_BADARG_RET((0>strLen), ippStsLengthErr);
+
+ return cpToOctStr_BNU(pOctStr,strLen, BN_NUMBER(pBN),BN_SIZE(pBN))? ippStsNoErr : ippStsLengthErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetref.c b/ext/ipp/sources/ippcp/pcpbngetref.c
new file mode 100644
index 0000000..fa45b68
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetref.c
@@ -0,0 +1,114 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsBigNumGetSize()
+// ippsBigNumInit()
+//
+// ippsSet_BN()
+// ippsGet_BN()
+// ippsGetSize_BN()
+// ippsExtGet_BN()
+// ippsRef_BN()
+//
+// ippsCmpZero_BN()
+// ippsCmp_BN()
+//
+// ippsAdd_BN()
+// ippsSub_BN()
+// ippsMul_BN()
+// ippsMAC_BN_I()
+// ippsDiv_BN()
+// ippsMod_BN()
+// ippsGcd_BN()
+// ippsModInv_BN()
+//
+// cpPackBigNumCtx(), cpUnpackBigNumCtx()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsRef_BN
+//
+// Purpose: Get BigNum info.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSgn pointer to the sign
+// pBitSize pointer to the data size (in bits)
+// ppData pointer to the data buffer
+// pBN BigNum ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsRef_BN, (IppsBigNumSGN* pSgn, int* pBitSize, Ipp32u** const ppData,
+ const IppsBigNumState *pBN))
+{
+ IPP_BAD_PTR1_RET(pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ if(pSgn)
+ *pSgn = BN_SIGN(pBN);
+ if(pBitSize) {
+ cpSize bitLen = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN));
+ *pBitSize = bitLen? bitLen : 1;
+ }
+
+ if(ppData)
+ *ppData = (Ipp32u*)BN_NUMBER(pBN);
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetsize.c b/ext/ipp/sources/ippcp/pcpbngetsize.c
new file mode 100644
index 0000000..7e636dc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetsize.c
@@ -0,0 +1,93 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsBigNumGetSize()
+// ippsBigNumInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsBigNumGetSize
+//
+// Purpose: Returns size of BigNum ctx (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtxSize == NULL
+// ippStsLengthErr length < 1
+// length > BITS2WORD32_SIZE(BN_MAXBITSIZE)
+// ippStsNoErr no errors
+//
+// Parameters:
+// length max BN length (32-bits segments)
+// pSize pointer BigNum ctx size
+//
+*F*/
+IPPFUN(IppStatus, ippsBigNumGetSize, (int length, cpSize *pCtxSize))
+{
+ IPP_BAD_PTR1_RET(pCtxSize);
+ IPP_BADARG_RET(length<1 || length>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
+
+ {
+ /* convert length to the number of BNU_CHUNK_T */
+ cpSize len = INTERNAL_BNU_LENGTH(length);
+
+ /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
+ mul, mont exp operations */
+ len++;
+
+ *pCtxSize = sizeof(IppsBigNumState)
+ + len*sizeof(BNU_CHUNK_T)
+ + len*sizeof(BNU_CHUNK_T)
+ + BN_ALIGNMENT-1;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbngetwords.c b/ext/ipp/sources/ippcp/pcpbngetwords.c
new file mode 100644
index 0000000..1cfa960
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbngetwords.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsGet_BN()
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGet_BN
+//
+// Purpose: Get BigNum.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// pData == NULL
+// pSgn == NULL
+// pLengthInBits ==NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSgn pointer to the sign
+// pLengthInBits pointer to the data size (in Ipp32u chunks)
+// pData pointer to the data buffer
+// pBN BigNum ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsGet_BN, (IppsBigNumSGN* pSgn, int* pLengthInBits, Ipp32u* pData,
+ const IppsBigNumState* pBN))
+{
+ IPP_BAD_PTR4_RET(pSgn, pLengthInBits, pData, pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ {
+ cpSize len32 = BN_SIZE(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
+ Ipp32u* bnData = (Ipp32u*)BN_NUMBER(pBN);
+
+ FIX_BNU(bnData, len32);
+ COPY_BNU(pData, bnData, len32);
+
+ *pSgn = BN_SIGN(pBN);
+ *pLengthInBits = len32;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbninit.c b/ext/ipp/sources/ippcp/pcpbninit.c
new file mode 100644
index 0000000..a2047cb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbninit.c
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsBigNumGetSize()
+// ippsBigNumInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsBigNumInit
+//
+// Purpose: Init BigNum spec for future usage.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// ippStsLengthErr length<1
+// length > BITS2WORD32_SIZE(BN_MAXBITSIZE)
+// ippStsNoErr no errors
+//
+// Parameters:
+// length max BN length (32-bits segments)
+// pBN BigNum ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsBigNumInit, (int length, IppsBigNumState* pBN))
+{
+ IPP_BADARG_RET(length<1 || length>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
+ IPP_BAD_PTR1_RET(pBN);
+ pBN = (IppsBigNumState*)(IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT));
+
+ {
+ Ipp8u* ptr = (Ipp8u*)pBN;
+
+ /* convert length to the number of BNU_CHUNK_T */
+ cpSize len = INTERNAL_BNU_LENGTH(length);
+
+ BN_ID(pBN) = idCtxUnknown;
+ BN_SIGN(pBN) = ippBigNumPOS;
+ BN_SIZE(pBN) = 1; /* initial valie is zero */
+ BN_ROOM(pBN) = len; /* close to what has been passed by user */
+
+ /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
+ mul, mont exp operations */
+ len++;
+
+ /* allocate buffers */
+ BN_NUMBER(pBN) = (BNU_CHUNK_T*)(ptr += sizeof(IppsBigNumState));
+ BN_BUFFER(pBN) = (BNU_CHUNK_T*)(ptr += len * sizeof(BNU_CHUNK_T)); /* use expanded length here */
+
+ /* set BN value and buffer to zero */
+ ZEXPAND_BNU(BN_NUMBER(pBN), 0, len);
+ ZEXPAND_BNU(BN_BUFFER(pBN), 0, len);
+
+ BN_ID(pBN) = idCtxBigNum;
+ return ippStsNoErr;
+ }
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpbnresource.h b/ext/ipp/sources/ippcp/pcpbnresource.h
new file mode 100644
index 0000000..28b67d3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnresource.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal BN Resource Definitions & Function Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_BNRESOURCE_H)
+#define _PCP_BNRESOURCE_H
+
+
+typedef struct {
+ void* pNext;
+ IppsBigNumState* pBN;
+} BigNumNode;
+
+
+/* size (byte) of BN resource */
+#define cpBigNumListGetSize OWNAPI(cpBigNumListGetSize)
+ int cpBigNumListGetSize(int feBitSize, int nodes);
+
+/* init BN resource */
+#define cpBigNumListInit OWNAPI(cpBigNumListInit)
+ void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList);
+
+/* get BN from resource */
+#define cpBigNumListGet OWNAPI(cpBigNumListGet)
+IppsBigNumState* cpBigNumListGet(BigNumNode** pList);
+
+#endif /* _PCP_BNRESOURCE_H */
diff --git a/ext/ipp/sources/ippcp/pcpbnresourceca.c b/ext/ipp/sources/ippcp/pcpbnresourceca.c
new file mode 100644
index 0000000..cd9f5ea
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnresourceca.c
@@ -0,0 +1,144 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal ECC (prime) Resource List Function
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbnresource.h"
+#include "pcpbn.h"
+
+
+
+/*F*
+// Name: cpBigNumListGetSize
+//
+// Purpose: Size of BigNum List Buffer
+//
+// Returns:
+// Size of List Buffer
+//
+// Parameters:
+// feBitSize size in bits
+// nodes number of nodes
+//
+*F*/
+
+int cpBigNumListGetSize(int feBitSize, int nodes)
+{
+ /* size of buffer per single big number */
+ int bnSize;
+ ippsBigNumGetSize(BITS2WORD32_SIZE(feBitSize), &bnSize);
+
+ /* size of buffer for whole list */
+ return (ALIGN_VAL-1) + (sizeof(BigNumNode) + bnSize) * nodes;
+}
+
+/*F*
+// Name: cpBigNumListInit
+//
+// Purpose: Init list
+//
+//
+// Parameters:
+// feBitSize size in bit
+// nodes number of nodes
+// pList pointer to list
+//
+// Note: buffer for BN list must have appropriate alignment
+//
+*F*/
+void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList)
+{
+ int itemSize;
+ /* length of Big Num */
+ int bnLen = BITS2WORD32_SIZE(feBitSize);
+ /* size of buffer per single big number */
+ ippsBigNumGetSize(bnLen, &itemSize);
+ /* size of list item */
+ itemSize += sizeof(BigNumNode);
+
+ {
+ int n;
+ /* init all nodes */
+ BigNumNode* pNode = (BigNumNode*)( (Ipp8u*)pList + (nodes-1)*itemSize );
+ BigNumNode* pNext = NULL;
+ for(n=0; n<nodes; n++) {
+ Ipp8u* tbnPtr = (Ipp8u*)pNode + sizeof(BigNumNode);
+ pNode->pNext = pNext;
+ pNode->pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(tbnPtr, ALIGN_VAL) );
+ ippsBigNumInit(bnLen, pNode->pBN);
+ pNext = pNode;
+ pNode = (BigNumNode*)( (Ipp8u*)pNode - itemSize);
+ }
+ }
+}
+
+
+/*F*
+// Name: cpBigNumListGet
+//
+// Purpose: Get BigNum reference
+//
+// Returns:
+// BigNum reference
+//
+// Parameters:
+// ppList pointer to pointer to List
+//
+*F*/
+
+IppsBigNumState* cpBigNumListGet(BigNumNode** ppList)
+{
+ if(*ppList) {
+ IppsBigNumState* ret = (*ppList)->pBN;
+ *ppList = (*ppList)->pNext;
+ return ret;
+ }
+ else
+ return NULL;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnsetoctstr.c b/ext/ipp/sources/ippcp/pcpbnsetoctstr.c
new file mode 100644
index 0000000..6a268ec
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnsetoctstr.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Big Number Operations
+//
+// Contents:
+// ippsSetOctString_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+
+
+/*F*
+// Name: ippsSetOctString_BN
+//
+// Purpose: Convert octet string into the BN value.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pOctStr
+// NULL == pBN
+//
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+//
+// ippStsLengthErr 0 > strLen
+//
+// ippStsSizeErr BN_ROOM(pBN) is enough for keep actual strLen
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pOctStr pointer to the source octet string
+// strLen octet string length
+// pBN pointer to the target BN
+//
+*F*/
+IPPFUN(IppStatus, ippsSetOctString_BN,(const Ipp8u* pOctStr, int strLen,
+ IppsBigNumState* pBN))
+{
+ IPP_BAD_PTR2_RET(pOctStr, pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ IPP_BADARG_RET((0>strLen), ippStsLengthErr);
+
+ /* remove leading zeros */
+ while(strLen && (0==pOctStr[0])) {
+ strLen--;
+ pOctStr++;
+ }
+
+ /* test BN size */
+ IPP_BADARG_RET((int)(sizeof(BNU_CHUNK_T)*BN_ROOM(pBN))<strLen, ippStsSizeErr);
+ if(strLen)
+ BN_SIZE(pBN) = cpFromOctStr_BNU(BN_NUMBER(pBN), pOctStr, strLen);
+ else {
+ BN_NUMBER(pBN)[0] = (BNU_CHUNK_T)0;
+ BN_SIZE(pBN) = 1;
+ }
+ BN_SIGN(pBN) = ippBigNumPOS;
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnsetwords.c b/ext/ipp/sources/ippcp/pcpbnsetwords.c
new file mode 100644
index 0000000..99f5d19
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnsetwords.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsSet_BN()
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsSet_BN
+//
+// Purpose: Set BigNum.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBN == NULL
+// pData == NULL
+// ippStsContextMatchErr !BN_VALID_ID(pBN)
+// ippStsLengthErr length < 1
+// ippStsOutOfRangeErr length > BN_ROOM(pBN)
+// ippStsNoErr no errors
+//
+// Parameters:
+// sgn sign
+// length data size (in Ipp32u chunks)
+// pData source data pointer
+// pBN BigNum ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsSet_BN, (IppsBigNumSGN sgn, int length, const Ipp32u* pData,
+ IppsBigNumState* pBN))
+{
+ IPP_BAD_PTR2_RET(pData, pBN);
+
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(length<1, ippStsLengthErr);
+
+ /* compute real size */
+ FIX_BNU(pData, length);
+
+ {
+ cpSize len = INTERNAL_BNU_LENGTH(length);
+ IPP_BADARG_RET(len > BN_ROOM(pBN), ippStsOutOfRangeErr);
+
+ ZEXPAND_COPY_BNU((Ipp32u*)BN_NUMBER(pBN), BN_ROOM(pBN)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pData, length);
+
+ BN_SIZE(pBN) = len;
+
+ if(length==1 && pData[0] == 0)
+ sgn = ippBigNumPOS; /* consider zero value as positive */
+ BN_SIGN(pBN) = sgn;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_add.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_add.c
new file mode 100644
index 0000000..1d88dfd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_add.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpAdd_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+
+/*F*
+// Name: cpSub_BNU32
+//
+// Purpose: addition BNU32.
+//
+// Returns:
+// carry
+//
+// Parameters:
+// pA source
+// pB source
+// ns size
+// pR result
+//
+*F*/
+Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns)
+{
+ Ipp32u carry = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ Ipp64u t = (Ipp64u)carry +pA[i] + pB[i];
+ pR[i] = LODWORD(t);
+ carry = HIDWORD(t);
+ }
+ return carry;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_dec.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_dec.c
new file mode 100644
index 0000000..fb1bf12
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_dec.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpDec_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+/*F*
+// Name: cpDec_BNU32
+//
+// Purpose: BNU32 decrement.
+//
+// Returns:
+// borrow
+//
+// Parameters:
+// pA source
+// pR result
+// ns size
+// v borrow
+//
+*F*/
+
+Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u v)
+{
+ Ipp32u borrow = v;
+ int n;
+ for(n=0; n<ns; n++) {
+ Ipp64u t = (Ipp64u)(pA[n]) - (Ipp64u)borrow;
+ pR[n] = LODWORD(t);
+ borrow = HIDWORD(t)>>(32-1);
+ }
+ return borrow;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_div.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_div.c
new file mode 100644
index 0000000..e240245
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_div.c
@@ -0,0 +1,200 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpDiv_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+
+/*F*
+// Name: cpDiv_BNU32
+//
+// Purpose: BNU32 division.
+//
+// Returns:
+// size of result
+//
+// Parameters:
+// pX source X
+// pY source Y
+// pQ source quotient
+// sizeQ pointer to max size of Q
+// sizeX size of A
+// sizeY size of B
+//
+*F*/
+
+#if !((_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8))
+int cpDiv_BNU32(Ipp32u* pQ, cpSize* sizeQ,
+ Ipp32u* pX, cpSize sizeX,
+ Ipp32u* pY, cpSize sizeY)
+{
+ FIX_BNU(pY,sizeY);
+ FIX_BNU(pX,sizeX);
+
+ /* special case */
+ if(sizeX < sizeY) {
+
+ if(pQ) {
+ pQ[0] = 0;
+ *sizeQ = 1;
+ }
+
+ return sizeX;
+ }
+
+ /* special case */
+ if(1 == sizeY) {
+ int i;
+ Ipp32u r = 0;
+ for(i=(int)sizeX-1; i>=0; i--) {
+ Ipp64u tmp = MAKEDWORD(pX[i],r);
+ Ipp32u q = LODWORD(tmp / pY[0]);
+ r = LODWORD(tmp - q*pY[0]);
+ if(pQ) pQ[i] = q;
+ }
+
+ pX[0] = r;
+
+ if(pQ) {
+ FIX_BNU(pQ,sizeX);
+ *sizeQ = sizeX;
+ }
+
+ return 1;
+ }
+
+
+ /* common case */
+ {
+ cpSize qs = sizeX-sizeY+1;
+
+ cpSize nlz = cpNLZ_BNU32(pY[sizeY-1]);
+
+ /* normalization */
+ pX[sizeX] = 0;
+ if(nlz) {
+ cpSize ni;
+
+ pX[sizeX] = pX[sizeX-1] >> (32-nlz);
+ for(ni=sizeX-1; ni>0; ni--)
+ pX[ni] = (pX[ni]<<nlz) | (pX[ni-1]>>(32-nlz));
+ pX[0] <<= nlz;
+
+ for(ni=sizeY-1; ni>0; ni--)
+ pY[ni] = (pY[ni]<<nlz) | (pY[ni-1]>>(32-nlz));
+ pY[0] <<= nlz;
+ }
+
+ /*
+ // division
+ */
+ {
+ Ipp32u yHi = pY[sizeY-1];
+
+ int i;
+ for(i=(int)qs-1; i>=0; i--) {
+ Ipp32u extend;
+
+ /* estimate digit of quotient */
+ Ipp64u tmp = MAKEDWORD(pX[i+sizeY-1], pX[i+sizeY]);
+ Ipp64u q = tmp / yHi;
+ Ipp64u r = tmp - q*yHi;
+
+ /* tune estimation above */
+ //for(; (q>=CONST_64(0x100000000)) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) {
+ for(; HIDWORD(q) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) {
+ q -= 1;
+ r += yHi;
+ if( HIDWORD(r) )
+ break;
+ }
+
+ /* multiply and subtract */
+ extend = cpSubMulDgt_BNU32(pX+i, pY, sizeY, (Ipp32u)q);
+ extend = (pX[i+sizeY] -= extend);
+
+ if(extend) { /* subtracted too much */
+ q -= 1;
+ extend = cpAdd_BNU32(pX+i, pY, pX+i, sizeY);
+ pX[i+sizeY] += extend;
+ }
+
+ /* store quotation digit */
+ if(pQ) pQ[i] = LODWORD(q);
+ }
+ }
+
+ /* de-normalization */
+ if(nlz) {
+ cpSize ni;
+ for(ni=0; ni<sizeX; ni++)
+ pX[ni] = (pX[ni]>>nlz) | (pX[ni+1]<<(32-nlz));
+ for(ni=0; ni<sizeY-1; ni++)
+ pY[ni] = (pY[ni]>>nlz) | (pY[ni+1]<<(32-nlz));
+ pY[sizeY-1] >>= nlz;
+ }
+
+ FIX_BNU(pX,sizeX);
+
+ if(pQ) {
+ FIX_BNU(pQ,qs);
+ *sizeQ = qs;
+ }
+
+ return sizeX;
+ }
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_inc.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_inc.c
new file mode 100644
index 0000000..8fe3f17
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_inc.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpInc_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+
+/*F*
+// Name: cpInc_BNU32
+//
+// Purpose: BNU32 increment.
+//
+// Returns:
+// carry
+//
+// Parameters:
+// pA source
+// pR result
+// ns size
+// v borrow
+//
+*F*/
+
+Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u v)
+{
+ Ipp32u carry = v;
+ cpSize i;
+ for(i=0; i<ns && carry; i++) {
+ Ipp64u t = (Ipp64u)carry +pA[i];
+ pR[i] = LODWORD(t);
+ carry = HIDWORD(t);
+ }
+ return carry;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_muldigit.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_muldigit.c
new file mode 100644
index 0000000..d989bd4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_muldigit.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpMulDgt_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+
+/*F*
+// Name: cpMulDgt_BNU32
+//
+// Purpose: multiply BNU32 digit.
+//
+// Returns:
+// carry
+//
+// Parameters:
+// pA source
+// nsA size of A
+// val carry
+// pR result
+//
+*F*/
+Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)
+{
+ Ipp32u carry = 0;
+ cpSize i;
+ for(i=0; i<nsA; i++) {
+ Ipp64u t = (Ipp64u)val * (Ipp64u)pA[i] + carry;
+ pR[i] = LODWORD(t);
+ carry = HIDWORD(t);
+ }
+ return carry;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_sub.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_sub.c
new file mode 100644
index 0000000..c354c5d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_sub.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpSub_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+
+/*F*
+// Name: cpSub_BNU32
+//
+// Purpose: substract BNU32.
+//
+// Returns:
+// borrow
+//
+// Parameters:
+// pA source
+// pB source
+// ns size
+// pR result
+//
+*F*/
+Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns)
+{
+ Ipp32u borrow = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ Ipp64u t = (Ipp64u)(pA[i]) - pB[i] - borrow;
+ pR[i] = LODWORD(t);
+ borrow = 0-HIDWORD(t);
+ }
+ return borrow;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_arith_submuldigit.c b/ext/ipp/sources/ippcp/pcpbnu32_arith_submuldigit.c
new file mode 100644
index 0000000..1dd18ee
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_arith_submuldigit.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal BNU32 arithmetic.
+//
+// Contents:
+// cpSubMulDgt_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+#include "pcpbnu32arith.h"
+
+/*F*
+// Name: cpMulDgt_BNU32
+//
+// Purpose: multiply and subtract BNU32.
+//
+// Returns:
+// carry
+//
+// Parameters:
+// pA source
+// nsA size of A
+// val digit to mul
+// pR result
+//
+*F*/
+
+#if !((_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8))
+Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)
+{
+ Ipp32u carry = 0;
+ for(; nsA>0; nsA--) {
+ Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry;
+ *pR++ = LODWORD(r);
+ carry = 0-HIDWORD(r);
+ }
+ return carry;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_getoctstr.c b/ext/ipp/sources/ippcp/pcpbnu32_getoctstr.c
new file mode 100644
index 0000000..3fc2930
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_getoctstr.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Unsigned internal BNU32 misc functionality
+//
+// Contents:
+// cpToOctStr_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuimpl.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+
+/*F*
+// Name: cpToOctStr_BNU32
+//
+// Purpose: Convert BNU into HexString representation.
+//
+// Returns:
+// length of the string or 0 if no success
+//
+// Parameters:
+// pBNU pointer to the source BN
+// bnuSize size of BN
+// pStr pointer to the target octet string
+// strLen octet string length
+*F*/
+
+cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize)
+{
+ FIX_BNU(pBNU, bnuSize);
+ {
+ int bnuBitSize = BITSIZE_BNU32(pBNU, bnuSize);
+ if(bnuBitSize <= strLen*BYTESIZE) {
+ Ipp32u x = pBNU[bnuSize-1];
+
+ ZEXPAND_BNU(pStr, 0, strLen);
+ pStr += strLen - BITS2WORD8_SIZE(bnuBitSize);
+
+ if(x) {
+ int nb;
+ for(nb=cpNLZ_BNU32(x)/BYTESIZE; nb<4; nb++)
+ *pStr++ = EBYTE(x,3-nb);
+
+ for(--bnuSize; bnuSize>0; bnuSize--) {
+ x = pBNU[bnuSize-1];
+ *pStr++ = EBYTE(x,3);
+ *pStr++ = EBYTE(x,2);
+ *pStr++ = EBYTE(x,1);
+ *pStr++ = EBYTE(x,0);
+ }
+ }
+ return strLen;
+ }
+ else
+ return 0;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_nlz.c b/ext/ipp/sources/ippcp/pcpbnu32_nlz.c
new file mode 100644
index 0000000..85eafe6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_nlz.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Unsigned internal BNU32 misc functionality
+//
+// Contents:
+// cpNLZ_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuimpl.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+
+/*F*
+// Name: cpNLZ_BNU32
+//
+// Purpose: Returns number of leading zeros of the 32-bit BN chunk.
+//
+// Returns:
+// number of leading zeros of the 32-bit BN chunk
+//
+// Parameters:
+// x BigNum x
+//
+*F*/
+
+cpSize cpNLZ_BNU32(Ipp32u x)
+{
+ cpSize nlz = BITSIZE(Ipp32u);
+ if(x) {
+ nlz = 0;
+ if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
+ if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
+ if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
+ if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
+ if( 0==(x & 0x80000000) ) { nlz++; }
+ }
+ return nlz;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32_setoctstr.c b/ext/ipp/sources/ippcp/pcpbnu32_setoctstr.c
new file mode 100644
index 0000000..44c7380
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32_setoctstr.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Unsigned internal BNU32 misc functionality
+//
+// Contents:
+// cpToOctStr_BNU32()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuimpl.h"
+#include "pcpbnumisc.h"
+#include "pcpbnu32misc.h"
+
+/*F*
+// Name: cpFromOctStr_BNU32
+//
+// Purpose: Convert Oct String into BNU representation.
+//
+// Returns:
+// size of BNU in BNU_CHUNK_T chunks
+//
+// Parameters:
+// pOctStr pointer to the source octet string
+// strLen octet string length
+// pBNU pointer to the target BN
+//
+*F*/
+
+cpSize cpFromOctStr_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, cpSize strLen)
+{
+ cpSize bnuSize=0;
+ *pBNU = 0;
+
+ /* start from the end of string */
+ for(; strLen>=4; bnuSize++,strLen-=4) {
+ /* pack 4 bytes into single Ipp32u value*/
+ *pBNU++ = ( pOctStr[strLen-4]<<(8*3) )
+ +( pOctStr[strLen-3]<<(8*2) )
+ +( pOctStr[strLen-2]<<(8*1) )
+ + pOctStr[strLen-1];
+ }
+
+ /* convert the beginning of the string */
+ if(strLen) {
+ Ipp32u x;
+ for(x=0; strLen>0; strLen--) {
+ Ipp32u d = *pOctStr++;
+ x = x*256 + d;
+ }
+ *pBNU++ = x;
+ bnuSize++;
+ }
+
+ return bnuSize? bnuSize : 1;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu32arith.h b/ext/ipp/sources/ippcp/pcpbnu32arith.h
new file mode 100644
index 0000000..7c79111
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32arith.h
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2012-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives.
+// Internal BNU32 arithmetic
+//
+//
+*/
+
+#if !defined(_CP_BNU32_ARITH_H)
+#define _CP_BNU32_ARITH_H
+
+#define cpAdd_BNU32 OWNAPI(cpAdd_BNU32)
+Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
+#define cpSub_BNU32 OWNAPI(cpSub_BNU32)
+Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
+#define cpInc_BNU32 OWNAPI(cpInc_BNU32)
+Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
+#define cpDec_BNU32 OWNAPI(cpDec_BNU32)
+Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
+
+#define cpMulDgt_BNU32 OWNAPI(cpMulDgt_BNU32)
+Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int ns, Ipp32u val);
+#define cpSubMulDgt_BNU32 OWNAPI(cpSubMulDgt_BNU32)
+Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int nsA, Ipp32u val);
+
+#define cpDiv_BNU32 OWNAPI(cpDiv_BNU32)
+int cpDiv_BNU32(Ipp32u* pQ, int* nsQ, Ipp32u* pX, int nsX, Ipp32u* pY, int nsY);
+#define cpMod_BNU32(pX,sizeX, pM,sizeM) cpDiv_BNU32(NULL,NULL, (pX),(sizeX), (pM),(sizeM))
+
+#define cpFromOS_BNU32 OWNAPI(cpFromOS_BNU32)
+int cpFromOS_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, int strLen);
+#define cpToOS_BNU32 OWNAPI(cpToOS_BNU32)
+int cpToOS_BNU32(Ipp8u* pStr, int strLen, const Ipp32u* pBNU, int bnuSize);
+
+#endif /* _CP_BNU32_ARITH_H */
diff --git a/ext/ipp/sources/ippcp/pcpbnu32misc.h b/ext/ipp/sources/ippcp/pcpbnu32misc.h
new file mode 100644
index 0000000..9cb25f2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu32misc.h
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Miscellaneous BNU 32 bit Definitions & Function Prototypes
+//
+//
+*/
+
+#if !defined(_CP_BNU32_MISC_H)
+#define _CP_BNU32_MISC_H
+
+
+/* bit operations */
+#define BITSIZE_BNU32(p,ns) ((ns)*BNU_CHUNK_32BIT-cpNLZ_BNU32((p)[(ns)-1]))
+
+/* number of leading/trailing zeros */
+#define cpNLZ_BNU32 OWNAPI(cpNLZ_BNU32)
+cpSize cpNLZ_BNU32(Ipp32u x);
+
+/* most significant BNU bit */
+__INLINE int cpMSBit_BNU32(const Ipp32u* pA, cpSize nsA)
+{
+ FIX_BNU(pA, nsA);
+ return nsA*BITSIZE(Ipp32u) - cpNLZ_BNU32(pA[nsA-1]) -1;
+}
+
+
+__INLINE int cpCmp_BNU32(const Ipp32u* pA, cpSize nsA, const Ipp32u* pB, cpSize nsB)
+{
+ if(nsA!=nsB)
+ return nsA>nsB? 1 : -1;
+ else {
+ for(; nsA>0; nsA--) {
+ if(pA[nsA-1] > pB[nsA-1])
+ return 1;
+ else if(pA[nsA-1] < pB[nsA-1])
+ return -1;
+ }
+ return 0;
+ }
+}
+
+/* to/from oct string conversion */
+#define cpToOctStr_BNU32 OWNAPI(cpToOctStr_BNU32)
+cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize);
+#define cpFromOctStr_BNU32 OWNAPI(cpFromOctStr_BNU32)
+cpSize cpFromOctStr_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, cpSize strLen);
+
+#endif /* _CP_BNU32_MISC_H */
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_add.c b/ext/ipp/sources/ippcp/pcpbnu_arith_add.c
new file mode 100644
index 0000000..ada82a3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_add.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpAdd_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpAdd_BNU
+//
+// Purpose: Addition of two BigNums.
+//
+// Returns:
+// carry of result of add two BigNums.
+//
+// Parameters:
+// pA source BigNum A
+// pB source BigNum B
+// pR resultant BigNum
+// ns size of BigNums
+*F*/
+#if defined(_USE_C_cpAdd_BNU_)
+#pragma message ("C version of cpAdd_BNU: ON")
+#else
+#pragma message ("C version of cpAdd_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpAdd_BNU_)
+BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns)
+{
+ BNU_CHUNK_T carry = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ ADD_ABC(carry, pR[i], pA[i],pB[i], carry);
+ }
+ return carry;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_addmuldigit.c b/ext/ipp/sources/ippcp/pcpbnu_arith_addmuldigit.c
new file mode 100644
index 0000000..4da1d4a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_addmuldigit.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpAddMulDgt_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+/*F*
+// Name: cpAddMulDgt_BNU
+//
+// Purpose: multiply-and-add BNU
+//
+// Returns:
+// extension of result of multiply-and-add BigNum.
+//
+// Parameters:
+// pA source BigNum A
+// pR resultant BigNum
+// ns size of BigNums
+// val value to multiply
+*F*/
+
+#if defined(_USE_C_cpAddMulDgt_BNU_)
+#pragma message ("C version of cpAddMulDgt_BNU: ON")
+#else
+#pragma message ("C version of cpAddMulDgt_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpAddMulDgt_BNU_)
+BNU_CHUNK_T cpAddMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
+{
+ BNU_CHUNK_T extension = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ BNU_CHUNK_T rH, rL;
+
+ MUL_AB(rH, rL, pA[i], val);
+ ADD_ABC(extension, pR[i], pR[i], rL, extension);
+ extension += rH;
+ }
+ return extension;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_dec.c b/ext/ipp/sources/ippcp/pcpbnu_arith_dec.c
new file mode 100644
index 0000000..b944d6a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_dec.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpDec_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+/*F*
+// Name: cpDec_BNU
+//
+// Purpose: decrement BigNum.
+//
+// Returns:
+// borrow of result of dec BigNum.
+//
+// Parameters:
+// pA source BigNum A
+// pR resultant BigNum
+// ns size of BigNum
+// val carry
+*F*/
+
+#if !((_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8))
+BNU_CHUNK_T cpDec_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
+{
+ cpSize i;
+ for(i=0; i<ns && val; i++) {
+ BNU_CHUNK_T borrow;
+ SUB_AB(borrow, pR[i], pA[i], val);
+ val = borrow;
+ }
+ if(pR!=pA)
+ for(; i<ns; i++)
+ pR[i] = pA[i];
+ return val;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_gcd.c b/ext/ipp/sources/ippcp/pcpbnu_arith_gcd.c
new file mode 100644
index 0000000..26b58b0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_gcd.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpGcd_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+/*F*
+// Name: cpGcd_BNU
+//
+// Purpose: compute GCD value.
+//
+// Returns:
+// GCD value
+//
+// Parameters:
+// a source BigNum
+// b source BigNum
+//
+*F*/
+
+BNU_CHUNK_T cpGcd_BNU(BNU_CHUNK_T a, BNU_CHUNK_T b)
+{
+ BNU_CHUNK_T gcd, t, r;
+
+ if(a > b){
+ gcd = a;
+ t = b;
+ } else {
+ t = a;
+ gcd = b;
+ }
+
+ while (t != 0) {
+ r = gcd % t;
+ gcd = t;
+ t = r;
+ }
+ return gcd;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_inc.c b/ext/ipp/sources/ippcp/pcpbnu_arith_inc.c
new file mode 100644
index 0000000..cb730fd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_inc.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpInc_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpInc_BNU
+//
+// Purpose: increment BigNum.
+//
+// Returns:
+// carry of result of inc BigNum.
+//
+// Parameters:
+// pA source BigNum A
+// pR resultant BigNum
+// ns size of BigNum
+// val carry
+*F*/
+#if defined(_USE_C_cpInc_BNU_)
+#pragma message ("C version of cpInc_BNU: ON")
+#else
+#pragma message ("C version of cpInc_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpInc_BNU_)
+BNU_CHUNK_T cpInc_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
+{
+ cpSize i;
+ for(i=0; i<ns && val; i++) {
+ BNU_CHUNK_T carry;
+ ADD_AB(carry, pR[i], pA[i], val);
+ val = carry;
+ }
+ if(pR!=pA)
+ for(; i<ns; i++)
+ pR[i] = pA[i];
+ return val;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_minv.c b/ext/ipp/sources/ippcp/pcpbnu_arith_minv.c
new file mode 100644
index 0000000..df65164
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_minv.c
@@ -0,0 +1,187 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpModInv_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*
+// cpMAC_BNU
+//
+// Multiply with ACcumulation
+// Computes r <- r + a * b, returns real size of the r in the size_r variable
+// Returns 0 if there are no enought buffer size to write to r[MAX(size_r + 1, size_a + size_b) - 1]
+// Returns 1 if no error
+//
+// Note:
+// DO NOT run in inplace mode
+// The minimum buffer size for the r must be (size_a + size_b - 1)
+// the maximum buffer size for the r is MAX(size_r + 1, size_a + size_b)
+*/
+static int cpMac_BNU(BNU_CHUNK_T* pR, cpSize nsR,
+ const BNU_CHUNK_T* pA, cpSize nsA,
+ const BNU_CHUNK_T* pB, cpSize nsB)
+{
+ /* cleanup the rest of destination buffer */
+ ZEXPAND_BNU(pR, nsR, nsA+nsB-1);
+ //nsR = IPP_MAX(nsR, nsA+nsB);
+
+ {
+ BNU_CHUNK_T expansion = 0;
+ cpSize i;
+ for(i=0; i<nsB && !expansion; i++) {
+ expansion = cpAddMulDgt_BNU(pR+i, pA, nsA, pB[i]);
+ if(expansion)
+ expansion = cpInc_BNU(pR+i+nsA, pR+i+nsA, nsR-i-nsA, expansion);
+ }
+
+ if(expansion)
+ return 0;
+ else { /* compute real size */
+ FIX_BNU(pR, nsR);
+ return nsR;
+ }
+ }
+}
+
+/*F*
+// Name: cpModInv_BNU
+//
+// Purpose: Multiplicative Inversion BigNum.
+//
+// Returns: Reason:
+//
+// Parameters:
+// pA source (value) BigNum A
+// nsA size of A
+// pM source (modulus) BigNum M
+// nsM size of M
+// pInv result BigNum
+// bufInv buffer of Inv
+// bufA buffer of A
+// bufM buffer of M
+//
+*F*/
+
+int cpModInv_BNU(BNU_CHUNK_T* pInv,
+ const BNU_CHUNK_T* pA, cpSize nsA,
+ const BNU_CHUNK_T* pM, cpSize nsM,
+ BNU_CHUNK_T* bufInv, BNU_CHUNK_T* bufA, BNU_CHUNK_T* bufM)
+{
+ FIX_BNU(pA, nsA);
+ FIX_BNU(pM, nsM);
+
+ /* inv(1) = 1 */
+ if(nsA==1 && pA[0]==1) {
+ pInv[0] = 1;
+ return 1;
+ }
+
+ {
+ cpSize moduloSize = nsM;
+
+ BNU_CHUNK_T* X1 = pInv;
+ BNU_CHUNK_T* X2 = bufM;
+ BNU_CHUNK_T* Q = bufInv;
+ cpSize nsX1 = 1;
+ cpSize nsX2 = 1;
+ cpSize nsQ;
+
+ COPY_BNU(bufA, pA, nsA);
+
+ ZEXPAND_BNU(X1, 0, moduloSize);
+ ZEXPAND_BNU(X2, 0, moduloSize);
+ X2[0] = 1;
+
+ //printf("\n");
+ for(;;) {
+ nsM = cpDiv_BNU(Q, &nsQ, (BNU_CHUNK_T*)pM, nsM, bufA, nsA);
+ //Print_BNU(" q: ", Q, nsQ);
+ //Print_BNU(" m: ", pM, nsM);
+ nsX1 = cpMac_BNU(X1,moduloSize, Q,nsQ, X2,nsX2);
+ //Print_BNU("X1: ", X1, nsX1);
+
+ if (nsM==1 && pM[0]==1) {
+ ////ZEXPAND_BNU(X2, nsX2, moduloSize);
+ nsX2 = cpMac_BNU(X2,moduloSize, X1,nsX1, bufA, nsA);
+ COPY_BNU((BNU_CHUNK_T*)pM, X2, moduloSize);
+ cpSub_BNU(pInv, pM, X1, moduloSize);
+ FIX_BNU(pInv, moduloSize);
+ return moduloSize;
+ }
+ else if (nsM==1 && pM[0]==0) {
+ cpMul_BNU_school((BNU_CHUNK_T*)pM, X1,nsX1, bufA, nsA);
+ /* gcd = buf_a */
+ return 0;
+ }
+
+ nsA = cpDiv_BNU(Q, &nsQ, bufA, nsA, (BNU_CHUNK_T*)pM, nsM);
+ //Print_BNU(" q: ", Q, nsQ);
+ //Print_BNU(" a: ", bufA, nsA);
+ nsX2 = cpMac_BNU(X2,moduloSize, Q,nsQ, X1,nsX1);
+ //Print_BNU("X2: ", X2, nsX2);
+
+ if(nsA==1 && bufA[0]==1) {
+ ////ZEXPAND_BNU(X1, nsX1, moduloSize);
+ nsX1 = cpMac_BNU(X1, moduloSize, X2, nsX2, pM, nsM);
+ COPY_BNU((BNU_CHUNK_T*)pM, X1, moduloSize);
+ COPY_BNU(pInv, X2, nsX2);
+ return nsX2;
+ }
+ else if (nsA==1 && bufA[0]==0) {
+ /* gcd = m */
+ COPY_BNU(X1, pM, nsM);
+ cpMul_BNU_school((BNU_CHUNK_T*)pM, X2, nsX2, X1, nsM);
+ return 0;
+ }
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_mul_adc.c b/ext/ipp/sources/ippcp/pcpbnu_arith_mul_adc.c
new file mode 100644
index 0000000..e88fd0f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_mul_adc.c
@@ -0,0 +1,114 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpMulAdc_BNU_school()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpMulAdc_BNU_school
+//
+// Purpose: Multiply 2 BigNums.
+//
+// Returns:
+// extention of result of multiply 2 BigNums
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// nsA size of A
+// nsB size of B
+// pR resultant BigNum
+//
+*F*/
+#if defined(_USE_C_cpMulAdc_BNU_school_)
+#pragma message ("C version of cpMulAdc_BNU_school: ON")
+#else
+#pragma message ("C version of cpMulAdc_BNU_school: OFF")
+#endif
+
+#if !((_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpMulAdc_BNU_school_)
+BNU_CHUNK_T cpMulAdc_BNU_school(BNU_CHUNK_T* pR,
+ const BNU_CHUNK_T* pA, cpSize nsA,
+ const BNU_CHUNK_T* pB, cpSize nsB)
+{
+ const BNU_CHUNK_T* pa = (BNU_CHUNK_T*)pA;
+ const BNU_CHUNK_T* pb = (BNU_CHUNK_T*)pB;
+ BNU_CHUNK_T* pr = (BNU_CHUNK_T*)pR;
+
+ BNU_CHUNK_T extension = 0;
+ cpSize i, j;
+
+ ZEXPAND_BNU(pr, 0, nsA+nsB);
+
+ for(i=0; i<nsB; i++ ) {
+ BNU_CHUNK_T b = pb[i];
+
+ for(j=0, extension=0; j<nsA; j++ ) {
+ BNU_CHUNK_T rH, rL;
+
+ MUL_AB(rH, rL, pa[j], b);
+ ADD_ABC(extension, pr[i+j], pr[i+j], rL, extension);
+ extension += rH;
+ }
+ pr[i+j] = extension;
+ }
+ return extension;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_sqr_adc.c b/ext/ipp/sources/ippcp/pcpbnu_arith_sqr_adc.c
new file mode 100644
index 0000000..1cfab64
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_sqr_adc.c
@@ -0,0 +1,130 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpSqrAdc_BNU_school()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpSqrAdc_BNU_school
+//
+// Purpose: Square BigNums.
+//
+// Returns:
+// extension of result of square BigNum
+//
+// Parameters:
+// pA source BigNum
+// pR resultant BigNum
+// nsA size of A
+//
+*F*/
+#if defined(_USE_C_cpSqrAdc_BNU_school_)
+#pragma message ("C version of cpSqrAdc_BNU_school: ON")
+#else
+#pragma message ("C version of cpSqrAdc_BNU_school: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpSqrAdc_BNU_school_)
+BNU_CHUNK_T cpSqrAdc_BNU_school(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA)
+{
+ cpSize i;
+
+ BNU_CHUNK_T extension;
+ BNU_CHUNK_T rH, rL;
+
+ /* init result */
+ pR[0] = 0;
+ for(i=1, extension=0; i<nsA; i++) {
+ MUL_AB(rH, rL, pA[i], pA[0]);
+ ADD_AB(extension, pR[i], rL, extension);
+ extension += rH;
+ }
+ pR[i] = extension;
+
+ /* add other a[i]*a[j] */
+ for(i=1; i<nsA-1; i++) {
+ BNU_CHUNK_T a = pA[i];
+ cpSize j;
+ for(j=i+1, extension=0; j<nsA; j++) {
+ MUL_AB(rH, rL, pA[j], a);
+ ADD_ABC(extension, pR[i+j], rL, pR[i+j], extension);
+ extension += rH;
+ }
+ pR[i+j] = extension;
+ }
+
+ /* double a[i]*a[j] */
+ for(i=1, extension=0; i<(2*nsA-1); i++) {
+ ADD_ABC(extension, pR[i], pR[i], pR[i], extension);
+ }
+ pR[i] = extension;
+
+ /* add a[i]^2 */
+ for(i=0, extension=0; i<nsA; i++) {
+ MUL_AB(rH, rL, pA[i], pA[i]);
+ ADD_ABC(extension, pR[2*i], pR[2*i], rL, extension);
+ ADD_ABC(extension, pR[2*i+1], pR[2*i+1], rH, extension);
+ }
+ return pR[2*nsA-1];
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_sub.c b/ext/ipp/sources/ippcp/pcpbnu_arith_sub.c
new file mode 100644
index 0000000..4e9039e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_sub.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpSub_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpSub_BNU
+//
+// Purpose: Subtraction of two BigNums.
+//
+// Returns:
+// borrow of result of sub two BigNums.
+//
+// Parameters:
+// pA source BigNum A
+// pB source BigNum B
+// pR resultant BigNum
+// ns size of BigNums
+*F*/
+#if defined(_USE_C_cpSub_BNU_)
+#pragma message ("C version of cpSub_BNU: ON")
+#else
+#pragma message ("C version of cpSub_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpSub_BNU_)
+BNU_CHUNK_T cpSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns)
+{
+ BNU_CHUNK_T borrow = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ SUB_ABC(borrow, pR[i], pA[i], pB[i], borrow);
+ }
+ return borrow;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_arith_submuldigit.c b/ext/ipp/sources/ippcp/pcpbnu_arith_submuldigit.c
new file mode 100644
index 0000000..8e66a40
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_arith_submuldigit.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned arithmetic
+//
+// Contents:
+// cpSubMulDgt_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpSubMulDgt_BNU
+//
+// Purpose: multiply-and-sub BNU
+//
+// Returns:
+// extension of result of multiply-and-sub BigNum.
+//
+// Parameters:
+// pA source BigNum A
+// pR resultant BigNum
+// ns size of BigNums
+// val value to multiply
+*F*/
+
+#if defined(_USE_C_cpSubMulDgt_BNU_)
+#pragma message ("C version of cpSubMulDgt_BNU: ON")
+#else
+#pragma message ("C version of cpSubMulDgt_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpSubMulDgt_BNU_)
+BNU_CHUNK_T cpSubMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
+{
+ BNU_CHUNK_T extension = 0;
+ cpSize i;
+ for(i=0; i<ns; i++) {
+ BNU_CHUNK_T rH, rL;
+
+ MUL_AB(rH, rL, pA[i], val);
+ SUB_ABC(extension, pR[i], pR[i], rL, extension);
+ extension += rH;
+ }
+ return extension;
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpbnu_getoctstr.c b/ext/ipp/sources/ippcp/pcpbnu_getoctstr.c
new file mode 100644
index 0000000..b578b4d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_getoctstr.c
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpToOctStr_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+
+/*
+// Convert BNU into HexString representation
+//
+// Returns length of the string or 0 if no success
+*/
+
+/*F*
+// Name: cpToOctStr_BNU
+//
+// Purpose: Convert BNU into HexString representation.
+//
+// Returns:
+// length of the string or 0 if no success
+//
+// Parameters:
+// pA pointer to the source BN A
+// nsA size of A
+// pStr pointer to the target octet string
+// strLen octet string length
+*F*/
+
+cpSize cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA)
+{
+ FIX_BNU(pA, nsA);
+ {
+ cpSize bnuBitSize = BITSIZE_BNU(pA, nsA);
+ if(bnuBitSize <= strLen*BYTESIZE) {
+ int cnvLen = 0;
+ BNU_CHUNK_T x = pA[nsA-1];
+
+ ZEXPAND_BNU(pStr, 0, strLen);
+ pStr += strLen - BITS2WORD8_SIZE(bnuBitSize);
+
+ if(x) {
+ //int nb;
+ cpSize nb;
+ for(nb=cpNLZ_BNU(x)/BYTESIZE; nb<(cpSize)(sizeof(BNU_CHUNK_T)); cnvLen++, nb++)
+ *pStr++ = EBYTE(x, sizeof(BNU_CHUNK_T)-1-nb);
+
+ for(--nsA; nsA>0; cnvLen+=sizeof(BNU_CHUNK_T), nsA--) {
+ x = pA[nsA-1];
+ #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
+ *pStr++ = EBYTE(x,7);
+ *pStr++ = EBYTE(x,6);
+ *pStr++ = EBYTE(x,5);
+ *pStr++ = EBYTE(x,4);
+ #endif
+ *pStr++ = EBYTE(x,3);
+ *pStr++ = EBYTE(x,2);
+ *pStr++ = EBYTE(x,1);
+ *pStr++ = EBYTE(x,0);
+ }
+ }
+ return strLen;
+ }
+ else
+ return 0;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_lsr.c b/ext/ipp/sources/ippcp/pcpbnu_lsr.c
new file mode 100644
index 0000000..c1fbd37
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_lsr.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpLSL_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpLSR_BNU
+//
+// Purpose: Logical shift right (including inplace).
+//
+// Returns:
+// new length
+//
+// Parameters:
+// pA BigNum A
+// pR result BigNum
+// nsA size of A
+// nBits size of shift in bits
+*F*/
+
+cpSize cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits)
+{
+ cpSize nw = nBits/BNU_CHUNK_BITS;
+ cpSize n;
+
+ pA += nw;
+ nsA -= nw;
+
+ nBits %= BNU_CHUNK_BITS;
+ if(nBits) {
+ BNU_CHUNK_T hi;
+ BNU_CHUNK_T lo = pA[0];
+
+ for(n=0; n<(nsA-1); n++) {
+ hi = pA[n+1];
+ pR[n] = (lo>>nBits) | (hi<<(BNU_CHUNK_BITS-nBits));
+ lo = hi;
+ }
+ pR[nsA-1] = (lo>>nBits);
+ }
+ else {
+ for(n=0; n<nsA; n++)
+ pR[n] = pA[n];
+ }
+
+ for(n=0; n<nw; n++)
+ pR[nsA+n] = 0;
+
+ return nsA+nw;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_msbit.c b/ext/ipp/sources/ippcp/pcpbnu_msbit.c
new file mode 100644
index 0000000..02154e1
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_msbit.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpMSBit_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+/*F*
+// Name: cpMSBit_BNU
+//
+// Purpose: Returns Most Significant Bit of the BNU.
+//
+// Returns:
+// Most Significant Bit of the BNU
+//
+// Parameters:
+// pA BigNum A
+// nsA size of A
+//
+// Note:
+// if BNU==0, -1 will return
+*F*/
+
+int cpMSBit_BNU(const BNU_CHUNK_T* pA, cpSize nsA)
+{
+ int msb;
+ FIX_BNU(pA, nsA);
+ msb = nsA*BNU_CHUNK_BITS - cpNLZ_BNU(pA[nsA-1]) -1;
+ return msb;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_nlz.c b/ext/ipp/sources/ippcp/pcpbnu_nlz.c
new file mode 100644
index 0000000..558d0b3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_nlz.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpNLZ_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpNLZ_BNU
+//
+// Purpose: Returns number of leading zeros of the BNU.
+//
+// Returns:
+// number of leading zeros of the BNU
+//
+// Parameters:
+// x BigNum x
+//
+*F*/
+
+cpSize cpNLZ_BNU(BNU_CHUNK_T x)
+{
+ cpSize nlz = BNU_CHUNK_BITS;
+ if(x) {
+ nlz = 0;
+ #if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT)
+ if( 0==(x & 0xFFFFFFFF00000000) ) { nlz +=32; x<<=32; }
+ if( 0==(x & 0xFFFF000000000000) ) { nlz +=16; x<<=16; }
+ if( 0==(x & 0xFF00000000000000) ) { nlz += 8; x<<= 8; }
+ if( 0==(x & 0xF000000000000000) ) { nlz += 4; x<<= 4; }
+ if( 0==(x & 0xC000000000000000) ) { nlz += 2; x<<= 2; }
+ if( 0==(x & 0x8000000000000000) ) { nlz++; }
+ #else
+ if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
+ if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
+ if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
+ if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
+ if( 0==(x & 0x80000000) ) { nlz++; }
+ #endif
+ }
+ return nlz;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_ntz.c b/ext/ipp/sources/ippcp/pcpbnu_ntz.c
new file mode 100644
index 0000000..5aa6887
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_ntz.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpNTZ_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+
+/*F*
+// Name: cpNTZ_BNU
+//
+// Purpose: Returns number of trailing zeros of the BNU.
+//
+// Returns:
+// number of trailing zeros of the BNU
+//
+// Parameters:
+// x BigNum x
+//
+*F*/
+
+cpSize cpNTZ_BNU(BNU_CHUNK_T x)
+{
+ cpSize ntz = BNU_CHUNK_BITS;
+ if(x) {
+ ntz = 0;
+ #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
+ if( 0==(x & 0x00000000FFFFFFFF) ) { ntz+=32; x>>=32; }
+ if( 0==(x & 0x000000000000FFFF) ) { ntz+=16; x>>=16; }
+ if( 0==(x & 0x00000000000000FF) ) { ntz+= 8; x>>= 8; }
+ if( 0==(x & 0x000000000000000F) ) { ntz+= 4; x>>= 4; }
+ if( 0==(x & 0x0000000000000003) ) { ntz+= 2; x>>= 2; }
+ if( 0==(x & 0x0000000000000001) ) { ntz++; }
+ #else
+ if( 0==(x & 0x0000FFFF) ) { ntz+=16; x>>=16; }
+ if( 0==(x & 0x000000FF) ) { ntz+= 8; x>>= 8; }
+ if( 0==(x & 0x0000000F) ) { ntz+= 4; x>>= 4; }
+ if( 0==(x & 0x00000003) ) { ntz+= 2; x>>= 2; }
+ if( 0==(x & 0x00000001) ) { ntz++; }
+ #endif
+ }
+ return ntz;
+}
diff --git a/ext/ipp/sources/ippcp/pcpbnu_setoctstr.c b/ext/ipp/sources/ippcp/pcpbnu_setoctstr.c
new file mode 100644
index 0000000..81c04fa
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpbnu_setoctstr.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal Unsigned BNU misc functionality
+//
+// Contents:
+// cpFromOctStr_BNU()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+
+/*F*
+// Name: cpFromOctStr_BNU
+//
+// Purpose: Convert Oct String into BNU representation.
+//
+// Returns:
+// size of BNU in BNU_CHUNK_T chunks
+//
+// Parameters:
+// pStr pointer to the source octet string
+// strLen octet string length
+// pA pointer to the target BN
+//
+*F*/
+
+cpSize cpFromOctStr_BNU(BNU_CHUNK_T* pA, const Ipp8u* pStr, cpSize strLen)
+{
+ int nsA =0;
+
+ /* start from the end of string */
+ for(; strLen>=(int)sizeof(BNU_CHUNK_T); nsA++,strLen-=(int)(sizeof(BNU_CHUNK_T))) {
+ /* pack sizeof(BNU_CHUNK_T) bytes into single BNU_CHUNK_T value*/
+ *pA++ =
+ #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
+ +( (BNU_CHUNK_T)pStr[strLen-8]<<(8*7) )
+ +( (BNU_CHUNK_T)pStr[strLen-7]<<(8*6) )
+ +( (BNU_CHUNK_T)pStr[strLen-6]<<(8*5) )
+ +( (BNU_CHUNK_T)pStr[strLen-5]<<(8*4) )
+ #endif
+ +( (BNU_CHUNK_T)pStr[strLen-4]<<(8*3) )
+ +( (BNU_CHUNK_T)pStr[strLen-3]<<(8*2) )
+ +( (BNU_CHUNK_T)pStr[strLen-2]<<(8*1) )
+ + (BNU_CHUNK_T)pStr[strLen-1];
+ }
+
+ /* convert the beginning of the string */
+ if(strLen) {
+ BNU_CHUNK_T x = 0;
+ for(x=0; strLen>0; strLen--) {
+ BNU_CHUNK_T d = *pStr++;
+ x = (x<<8) + d;
+ }
+ *pA++ = x;
+ nsA++;
+ }
+
+ return nsA;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpbnuarith.h b/ext/ipp/sources/ippcp/pcpbnuarith.h
index eaca1a2..be719b4 100644
--- a/ext/ipp/sources/ippcp/src/pcpbnuarith.h
+++ b/ext/ipp/sources/ippcp/pcpbnuarith.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2012-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Purpose:
@@ -27,7 +51,6 @@
#include "pcpbnuimpl.h"
#include "pcpbnu32arith.h"
-#include "pcpmulbnukara.h"
#define cpAdd_BNU OWNAPI(cpAdd_BNU)
BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns);
@@ -38,13 +61,6 @@ BNU_CHUNK_T cpInc_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHU
#define cpDec_BNU OWNAPI(cpDec_BNU)
BNU_CHUNK_T cpDec_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val);
-#if defined(_USE_KARATSUBA_)
-#define cpAddAdd_BNU OWNAPI(cpAddAdd_BNU)
-BNU_CHUNK_T cpAddAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize size);
-#define cpAddSub_BNU OWNAPI(cpAddSub_BNU)
-BNU_CHUNK_T cpAddSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize size);
-#endif
-
#define cpAddMulDgt_BNU OWNAPI(cpAddMulDgt_BNU)
BNU_CHUNK_T cpAddMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val);
@@ -58,6 +74,23 @@ BNU_CHUNK_T cpMulAdx_BNU_school(BNU_CHUNK_T* pR,
const BNU_CHUNK_T* pA, cpSize nsA,
const BNU_CHUNK_T* pB, cpSize nsB);
+/*F*
+// Name: cpMul_BNU_school
+//
+// Purpose: Multiply 2 BigNums.
+//
+// Returns:
+// extension of result of multiply 2 BigNums
+//
+// Parameters:
+// pA source BigNum A
+// nsA size of A
+// pB source BigNum B
+// nsB size of B
+// pR resultant BigNum
+//
+*F*/
+
__INLINE BNU_CHUNK_T cpMul_BNU_school(BNU_CHUNK_T* pR,
const BNU_CHUNK_T* pA, cpSize nsA,
const BNU_CHUNK_T* pB, cpSize nsB)
@@ -65,8 +98,8 @@ __INLINE BNU_CHUNK_T cpMul_BNU_school(BNU_CHUNK_T* pR,
#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_)
return cpMulAdx_BNU_school(pR, pA,nsA, pB,nsB);
#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_)
- return IsFeatureEnabled(ADCOX_ENABLED)? cpMulAdx_BNU_school(pR, pA,nsA, pB,nsB)
- : cpMulAdc_BNU_school(pR, pA,nsA, pB,nsB);
+ return IsFeatureEnabled(ippCPUID_ADCOX)? cpMulAdx_BNU_school(pR, pA,nsA, pB,nsB)
+ : cpMulAdc_BNU_school(pR, pA,nsA, pB,nsB);
#else
return cpMulAdc_BNU_school(pR, pA,nsA, pB,nsB);
#endif
@@ -79,13 +112,27 @@ BNU_CHUNK_T cpSqrAdc_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize
#define cpSqrAdx_BNU_school OWNAPI(cpSqrAdx_BNU_school)
BNU_CHUNK_T cpSqrAdx_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize nsA);
+/*F*
+// Name: cpSqr_BNU_school
+//
+// Purpose: Square BigNum.
+//
+// Returns:
+// extension of result of square BigNum
+//
+// Parameters:
+// pA source BigNum
+// pR resultant BigNum
+//
+*F*/
+
__INLINE BNU_CHUNK_T cpSqr_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize nsA)
{
#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_)
return cpSqrAdx_BNU_school(pR, pA,nsA);
#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_)
- return IsFeatureEnabled(ADCOX_ENABLED)? cpSqrAdx_BNU_school(pR, pA,nsA)
- : cpSqrAdc_BNU_school(pR, pA,nsA);
+ return IsFeatureEnabled(ippCPUID_ADCOX)? cpSqrAdx_BNU_school(pR, pA,nsA)
+ : cpSqrAdc_BNU_school(pR, pA,nsA);
#else
return cpSqrAdc_BNU_school(pR, pA,nsA);
#endif
@@ -104,48 +151,40 @@ int cpModInv_BNU(BNU_CHUNK_T* pInv,
/*
// multiplication/squaring wrappers
*/
-__INLINE cpSize cpMul_BNU_BufferSize(cpSize opLen)
-{
-#if !defined (_USE_KARATSUBA_)
- UNREFERENCED_PARAMETER(opLen);
- return 0;
-#else
- return cpKaratsubaBufferSize(opLen);
-#endif
-}
__INLINE BNU_CHUNK_T cpMul_BNU(BNU_CHUNK_T* pR,
const BNU_CHUNK_T* pA, cpSize nsA,
const BNU_CHUNK_T* pB, cpSize nsB,
BNU_CHUNK_T* pBuffer)
{
-#if !defined(_USE_KARATSUBA_)
UNREFERENCED_PARAMETER(pBuffer);
return cpMul_BNU_school(pR, pA,nsA, pB,nsB);
-#else
- if(nsA!=nsB || nsA<CP_KARATSUBA_MUL_THRESHOLD || !pBuffer)
- return cpMul_BNU_school(pR, pA,nsA, pB,nsB);
- else
- return cpMul_BNU_karatsuba(pR, pA,pB,nsA, pBuffer);
-#endif
}
__INLINE BNU_CHUNK_T cpSqr_BNU(BNU_CHUNK_T * pR,
const BNU_CHUNK_T * pA, cpSize nsA,
BNU_CHUNK_T* pBuffer)
{
-#if !defined(_USE_KARATSUBA_)
UNREFERENCED_PARAMETER(pBuffer);
return cpSqr_BNU_school(pR, pA,nsA);
-#else
- if(nsA<CP_KARATSUBA_SQR_THRESHOLD || !pBuffer)
- return cpSqr_BNU_school(pR, pA,nsA);
- else
- return cpSqr_BNU_karatsuba(pR, pA,nsA, pBuffer);
-#endif
}
-/*
-// division/reduction wrappers
-*/
+/*F*
+// Name: cpDiv_BNU
+//
+// Purpose: division/reduction BigNums.
+//
+// Returns:
+// size of result
+//
+// Parameters:
+// pA source BigNum
+// pB source BigNum
+// pQ quotient BigNum
+// pnsQ pointer to max size of Q
+// nsA size of A
+// nsB size of B
+//
+*F*/
+
__INLINE cpSize cpDiv_BNU(BNU_CHUNK_T* pQ, cpSize* pnsQ, BNU_CHUNK_T* pA, cpSize nsA, BNU_CHUNK_T* pB, cpSize nsB)
{
int nsR = cpDiv_BNU32((Ipp32u*)pQ, pnsQ,
@@ -162,6 +201,22 @@ __INLINE cpSize cpDiv_BNU(BNU_CHUNK_T* pQ, cpSize* pnsQ, BNU_CHUNK_T* pA, cpSize
return nsR;
}
+/*F*
+// Name: cpMod_BNU
+//
+// Purpose: reduction BigNums.
+//
+// Returns:
+// cpDiv_BNU(NULL,NULL, pX,nsX, pModulus, nsM)
+//
+// Parameters:
+// pX source BigNum
+// pModulus source BigNum
+// nsX size of X
+// nsM size of Modulus
+//
+*F*/
+
__INLINE cpSize cpMod_BNU(BNU_CHUNK_T* pX, cpSize nsX, BNU_CHUNK_T* pModulus, cpSize nsM)
{
return cpDiv_BNU(NULL,NULL, pX,nsX, pModulus, nsM);
diff --git a/ext/ipp/sources/ippcp/src/pcpbnuimpl.h b/ext/ipp/sources/ippcp/pcpbnuimpl.h
index bcb2e0b..ce2f286 100644
--- a/ext/ipp/sources/ippcp/src/pcpbnuimpl.h
+++ b/ext/ipp/sources/ippcp/pcpbnuimpl.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2012-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Purpose:
@@ -49,9 +73,9 @@
#define BNU_CHUNK_MASK (~(BNU_CHUNK_T)(0))
#if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT)
- //#pragma message ("BNU_CHUNK_BITS = 64 bit")
+ #pragma message ("BNU_CHUNK_BITS = 64 bit")
#elif (BNU_CHUNK_BITS == BNU_CHUNK_32BIT)
- //#pragma message ("BNU_CHUNK_BITS = 32 bit")
+ #pragma message ("BNU_CHUNK_BITS = 32 bit")
#else
#error BNU_CHUNK_BITS should be either 64 or 32 bit!
#endif
diff --git a/ext/ipp/sources/ippcp/src/pcpbnumisc.h b/ext/ipp/sources/ippcp/pcpbnumisc.h
index b7c8525..d3e50dc 100644
--- a/ext/ipp/sources/ippcp/src/pcpbnumisc.h
+++ b/ext/ipp/sources/ippcp/pcpbnumisc.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Purpose:
@@ -80,18 +104,41 @@ __INLINE void cpSet_BNU(BNU_CHUNK_T* pDst, cpSize ns, BNU_CHUNK_T val)
}
/* fix up */
+
+/* Name: cpFix_BNU
+//
+// Purpose: fix up BigNums.
+//
+// Returns:
+// fixed nsA
+//
+// Parameters:
+// pA BigNum ctx
+// nsA Size of pA
+//
+*/
+
__INLINE int cpFix_BNU(const BNU_CHUNK_T* pA, int nsA)
{
FIX_BNU(pA, nsA);
return nsA;
}
-/* comparison
+/* Name: cpCmp_BNU
//
-// returns
+// Purpose: Compare two BigNums.
+//
+// Returns:
// negative, if A < B
// 0, if A = B
// positive, if A > B
+//
+// Parameters:
+// pA BigNum ctx
+// nsA Size of pA
+// pB BigNum ctx
+// nsB Size of pB
+//
*/
__INLINE int cpCmp_BNU(const BNU_CHUNK_T* pA, cpSize nsA, const BNU_CHUNK_T* pB, cpSize nsB)
{
@@ -107,6 +154,22 @@ __INLINE int cpCmp_BNU(const BNU_CHUNK_T* pA, cpSize nsA, const BNU_CHUNK_T* pB,
return 0;
}
}
+
+/* Name: cpEqu_BNU_CHUNK
+//
+// Purpose: Compare two BNU_CHUNKs.
+//
+// Returns:
+// positive, if A = b
+// 0 , if A != b
+//
+// Parameters:
+// pA BigNum ctx
+// nsA Size of pA
+// b BNU_CHUNK_T to compare
+//
+*/
+
__INLINE int cpEqu_BNU_CHUNK(const BNU_CHUNK_T* pA, cpSize nsA, BNU_CHUNK_T b)
{
return (pA[0]==b && 1==cpFix_BNU(pA, nsA));
diff --git a/ext/ipp/sources/ippcp/pcpcmac.h b/ext/ipp/sources/ippcp/pcpcmac.h
new file mode 100644
index 0000000..3680f11
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpcmac.h
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2007-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Ciper-based Message Authentication Code (CMAC) see SP800-38B
+// Internal Definitions and Internal Functions Prototypes
+//
+*/
+
+#if !defined(_PCP_CMAC_H)
+#define _PCP_CMAC_H
+
+#include "pcprij.h"
+
+
+/*
+// Rijndael128 based CMAC context
+*/
+struct _cpAES_CMAC {
+ IppCtxId idCtx; /* CMAC identifier */
+ int index; /* internal buffer entry (free) */
+ int dummy[2]; /* align-16 */
+ Ipp8u k1[MBS_RIJ128]; /* k1 subkey */
+ Ipp8u k2[MBS_RIJ128]; /* k2 subkey */
+ Ipp8u mBuffer[MBS_RIJ128];/* buffer */
+ Ipp8u mMAC[MBS_RIJ128]; /* intermediate digest */
+ __ALIGN16 /* aligned AES context */
+ IppsRijndael128Spec mCipherCtx;
+};
+
+/* alignment */
+//#define CMACRIJ_ALIGNMENT (RIJ_ALIGNMENT)
+#define AESCMAC_ALIGNMENT (RIJ_ALIGNMENT)
+
+/*
+// Useful macros
+*/
+#define CMAC_ID(stt) ((stt)->idCtx)
+#define CMAC_INDX(stt) ((stt)->index)
+#define CMAC_K1(stt) ((stt)->k1)
+#define CMAC_K2(stt) ((stt)->k2)
+#define CMAC_BUFF(stt) ((stt)->mBuffer)
+#define CMAC_MAC(stt) ((stt)->mMAC)
+#define CMAC_CIPHER(stt) ((stt)->mCipherCtx)
+
+/* valid context ID */
+#define VALID_AESCMAC_ID(ctx) (CMAC_ID((ctx))==idCtxCMAC)
+
+#endif /* _PCP_CMAC_H */
diff --git a/ext/ipp/sources/ippcp/pcpdes.h b/ext/ipp/sources/ippcp/pcpdes.h
new file mode 100644
index 0000000..8d74695
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpdes.h
@@ -0,0 +1,118 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal DES based Encrypt/Decrypt Function Prototypes
+//
+//
+*/
+
+
+#if !defined(_PCP_DES_H)
+#define _PCP_DES_H
+
+
+/*
+// really DES round key saved in terms of pear of 24-bit half mentioned in FIPS 46-3
+*/
+typedef Ipp64u RoundKeyDES;
+typedef Ipp32u HalfRoundKeyDES;
+
+/*
+// DES context
+*/
+struct _cpDES {
+ IppCtxId idCtx; /* DES spec identifier */
+ Ipp32u dummy; /* alignment only (linux problem)*/
+ RoundKeyDES enc_keys[16]; /* array of keys for encryprion */
+ RoundKeyDES dec_keys[16]; /* array of keys for decryprion */
+};
+
+/* alignment */
+#define DES_ALIGNMENT ((int)(sizeof(Ipp64u)))
+
+#define MBS_DES (8) /* data block (bytes) */
+
+/*
+// Useful macros
+*/
+#define DES_ID(ctx) ((ctx)->idCtx)
+#define DES_EKEYS(ctx) ((ctx)->enc_keys)
+#define DES_DKEYS(ctx) ((ctx)->dec_keys)
+#define DES_ID_TEST(ctx) (DES_ID((ctx))==idCtxDES)
+
+/*
+// Internal Tables
+*/
+#define MITIGATED (4)
+
+#define IMPLEMENTATION MITIGATED
+
+
+#if (IMPLEMENTATION == MITIGATED)
+ extern const __ALIGN64 Ipp32u DESspbox[16*16];
+#endif
+
+
+/*
+// internal functions
+*/
+#define SetKey_DES OWNAPI(SetKey_DES)
+ void SetKey_DES(const Ipp8u* pKey, IppsDESSpec* pCtx);
+
+#define Cipher_DES OWNAPI(Cipher_DES)
+ Ipp64u Cipher_DES(Ipp64u inpBlk, const RoundKeyDES* pRKey, const Ipp32u spbox[]);
+
+#define ENCRYPT_DES(blk, pCtx) Cipher_DES((blk), DES_EKEYS((pCtx)), DESspbox)
+#define DECRYPT_DES(blk, pCtx) Cipher_DES((blk), DES_DKEYS((pCtx)), DESspbox)
+
+/* TDES prototypes */
+#define ECB_TDES OWNAPI(ECB_TDES)
+ void ECB_TDES(const Ipp64u* pSrc, Ipp64u* pDst, int nBlocks, const RoundKeyDES* pRKey[3], const Ipp32u spbox[]);
+#define EncryptCBC_TDES OWNAPI(EncryptCBC_TDES)
+ void EncryptCBC_TDES(const Ipp64u* pSrc, Ipp64u* pDst, int nBlocks, const RoundKeyDES* pRKey[3], Ipp64u iv, const Ipp32u spbox[]);
+#define DecryptCBC_TDES OWNAPI(DecryptCBC_TDES)
+ void DecryptCBC_TDES(const Ipp64u* pSrc, Ipp64u* pDst, int nBlocks, const RoundKeyDES* pRKey[3], Ipp64u iv, const Ipp32u spbox[]);
+
+#endif /* _PCP_DES_H */
diff --git a/ext/ipp/sources/ippcp/pcpdlp.h b/ext/ipp/sources/ippcp/pcpdlp.h
new file mode 100644
index 0000000..e2bccd4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpdlp.h
@@ -0,0 +1,144 @@
+/*******************************************************************************
+* Copyright 2005-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal DL (prime) basic Definitions & Function Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_DLP_H)
+#define _PCP_DLP_H
+
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcpprimeg.h"
+#include "pcpbnresource.h"
+
+/*
+// DLP context
+*/
+
+//#define MIN_DLP_BITSIZE (512)
+//#define MAX_DLP_BITSIZE (2048)
+//#define DEF_DLP_BITSIZER (160)
+
+struct _cpDLP {
+ IppCtxId idCtx; /* DL identifier */
+ Ipp32u flag; /* complete flag */
+
+ int bitSizeP; /* DH bitsize (P) */
+ int bitSizeR; /* DH bitsize (R) */
+
+ int method; /* exponentiation method: binary/window */
+ gsModEngine* pMontP0; /* Montgomery P-engine */
+ gsModEngine* pMontP1; /* Montgomery P-engine (for multithread version) */
+ gsModEngine* pMontR; /* Montgomery R-engine */
+
+ IppsBigNumState* pGenc; /* P-encoded DL generator */
+ IppsBigNumState* pX; /* private key */
+ IppsBigNumState* pYenc; /* P-encoded public key */
+
+ IppsPrimeState* pPrimeGen; /* prime generator */
+
+ BNU_CHUNK_T* pMeTable; /* pre-computed multi-exp table */
+
+ BigNumNode* pBnList; /* BN resource */
+ #if defined(_USE_WINDOW_EXP_)
+ BNU_CHUNK_T* pBnuList0; /* BNU resource */
+ BNU_CHUNK_T* pBnuList1; /* BNU resource (for multithread version) */
+ #endif
+};
+
+/*
+// Exponentiation method
+*/
+#define BINARY (0)
+#define WINDOW ((BINARY)+1)
+
+#define BNLISTSIZE (8) /* list size */
+
+/*
+// Contetx Access Macros
+*/
+#define DLP_ID(ctx) ((ctx)->idCtx)
+#define DLP_FLAG(ctx) ((ctx)->flag)
+#define DLP_BITSIZEP(ctx) ((ctx)->bitSizeP)
+#define DLP_BITSIZER(ctx) ((ctx)->bitSizeR)
+#define DLP_EXPMETHOD(ctx) ((ctx)->method)
+
+#define DLP_MONTP0(ctx) ((ctx)->pMontP0)
+#define DLP_MONTP1(ctx) ((ctx)->pMontP1)
+#define DLP_MONTR(ctx) ((ctx)->pMontR)
+
+#define DLP_P(ctx) (MOD_MODULUS(DLP_MONTP0((ctx))))
+#define DLP_R(ctx) (MOD_MODULUS(DLP_MONTR((ctx))))
+#define DLP_GENC(ctx) ((ctx)->pGenc)
+#define DLP_X(ctx) ((ctx)->pX)
+#define DLP_YENC(ctx) ((ctx)->pYenc)
+
+#define DLP_PRIMEGEN(ctx) ((ctx)->pPrimeGen)
+
+#define DLP_METBL(ctx) ((ctx)->pMeTable)
+#define DLP_BNCTX(ctx) ((ctx)->pBnList)
+#if defined(_USE_WINDOW_EXP_)
+#define DLP_BNUCTX0(ctx) ((ctx)->pBnuList0)
+#define DLP_BNUCTX1(ctx) ((ctx)->pBnuList1)
+#endif
+
+#define DLP_VALID_ID(ctx) (DLP_ID((ctx))==idCtxDLP)
+#define DLP_COMPLETE(ctx) (DLP_FLAG((ctx))==(IppDLPkeyP|IppDLPkeyR|IppDLPkeyG))
+
+/* alignment */
+#define DLP_ALIGNMENT ((int)(sizeof(void*)))
+
+/* pool size for gsModEngine */
+#define DLP_MONT_POOL_LENGTH (6)
+
+#define cpPackDLPCtx OWNAPI(cpPackDLPCtx)
+ void cpPackDLPCtx(const IppsDLPState* pDLP, Ipp8u* pBuffer);
+#define cpUnpackDLPCtx OWNAPI(cpUnpackDLPCtx)
+ void cpUnpackDLPCtx(const Ipp8u* pBuffer, IppsDLPState* pDLP);
+
+#endif /* _PCP_DLP_H */
diff --git a/ext/ipp/sources/ippcp/pcpecc_psetdp.c b/ext/ipp/sources/ippcp/pcpecc_psetdp.c
new file mode 100644
index 0000000..fe7a555
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpecc_psetdp.c
@@ -0,0 +1,154 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ECCPSetDP()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSet
+//
+// Purpose: Set EC Domain Parameters.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pPrime
+// NULL == pA
+// NULL == pB
+// NULL == pGX
+// NULL == pGY
+// NULL == pOrder
+// NULL == pECC
+//
+// ippStsContextMatchErr illegal pPrime->idCtx
+// illegal pA->idCtx
+// illegal pB->idCtx
+// illegal pGX->idCtx
+// illegal pGY->idCtx
+// illegal pOrder->idCtx
+// illegal pECC->idCtx
+//
+// ippStsRangeErr not enough room for:
+// pPrime
+// pA, pB,
+// pGX,pGY
+// pOrder
+//
+// ippStsRangeErr 0>= cofactor
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrime pointer to the prime (specify FG(p))
+// pA pointer to the A coefficient of EC equation
+// pB pointer to the B coefficient of EC equation
+// pGX,pGY pointer to the Base Point (x and y coordinates) of EC
+// pOrder pointer to the Base Point order
+// cofactor cofactor value
+// pECC pointer to the ECC context
+//
+*F*/
+IppStatus ECCPSetDP(const IppsGFpMethod* method,
+ int pLen, const BNU_CHUNK_T* pP,
+ int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState * pGF = ECP_GFP(pEC);
+
+ IppStatus sts = ippStsNoErr;
+ IppsBigNumState P, H;
+ int primeBitSize = BITSIZE_BNU(pP, pLen);
+ //cpConstructBN(&P, pLen, (BNU_CHUNK_T*)pP, NULL);
+ //sts = cpGFpSetGFp(&P, primeBitSize, method, pGF);
+ cpGFpSetGFp(pP, primeBitSize, method, pGF);
+
+ if(ippStsNoErr==sts) {
+ gsModEngine* pGFE = GFP_PMA(pGF);
+
+ do {
+ int elemLen = GFP_FELEN(pGFE);
+ IppsGFpElement elmA, elmB;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ sts = ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ if(ippStsNoErr!=sts) break;
+ sts = ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ if(ippStsNoErr!=sts) break;
+ /* and set EC */
+ sts = ippsGFpECSet(&elmA, &elmB, pEC);
+ if(ippStsNoErr!=sts) break;
+
+ /* convert GX ans GY coeffs into GF elements */
+ cpConstructBN(&P, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ sts = ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ if(ippStsNoErr!=sts) break;
+ sts = ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ if(ippStsNoErr!=sts) break;
+ /* and init EC subgroup */
+ sts = ippsGFpECSetSubgroup(&elmA, &elmB, &P, &H, pEC);
+ } while(0);
+
+ cpGFpReleasePool(2, pGFE);
+ }
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp.h b/ext/ipp/sources/ippcp/pcpeccp.h
index 6e96f49..d390645 100644
--- a/ext/ipp/sources/ippcp/src/pcpeccp.h
+++ b/ext/ipp/sources/ippcp/pcpeccp.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -27,10 +51,6 @@
#define _NEW_PCP_ECCP_H
#include "pcpgfpecstuff.h"
-//#include "pcpbnresource.h"
-//#include "pcppma.h"
-//#include "pcpeccppoint.h"
-//#include "pcpeccpsscm.h"
__INLINE IppsBigNumState* cpConstructBN(IppsBigNumState* pBN, cpSize len, BNU_CHUNK_T* pData, BNU_CHUNK_T* pBuffer)
@@ -45,6 +65,7 @@ __INLINE IppsBigNumState* cpConstructBN(IppsBigNumState* pBN, cpSize len, BNU_CH
}
/* set EC parameters */
+#define ECCPSetDP OWNAPI(ECCPSetDP)
IppStatus ECCPSetDP(const IppsGFpMethod* method,
int pLen, const BNU_CHUNK_T* pP,
int aLen, const BNU_CHUNK_T* pA,
diff --git a/ext/ipp/sources/ippcp/pcpeccpaddpoint.c b/ext/ipp/sources/ippcp/pcpeccpaddpoint.c
new file mode 100644
index 0000000..308d16d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpaddpoint.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPAddPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPAddPoint
+//
+// Purpose: Perforn EC point operation: R = P+Q
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pP
+// NULL == pQ
+// NULL == pR
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pP->idCtx
+// illegal pQ->idCtx
+// illegal pR->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pP pointer to the source EC Point context
+// pQ pointer to the source EC Point context
+// pR pointer to the resultant EC Point context
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP,
+ const IppsECCPPointState* pQ,
+ IppsECCPPointState* pR,
+ IppsECCPState* pEC))
+{
+ return ippsGFpECAddPoint(pP, pQ, pR, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd192r1.c b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd192r1.c
new file mode 100644
index 0000000..e47cac3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd192r1.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPBindGxyTblStd192r1()
+//
+*/
+
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPBindGxyTblStd192r1
+//
+// Purpose: Enable the use of base point-based pre-computed
+// tables of standard elliptic curves for EC192r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPBindGxyTblStd192r1,(IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP192r1_fun();
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd224r1.c b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd224r1.c
new file mode 100644
index 0000000..a45943a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd224r1.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPBindGxyTblStd224r1()
+//
+*/
+
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPBindGxyTblStd224r1
+//
+// Purpose: Enable the use of base point-based pre-computed
+// tables of standard elliptic curves for EC224r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPBindGxyTblStd224r1,(IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP224r1_fun();
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd256r1.c b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd256r1.c
new file mode 100644
index 0000000..b1fc81b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd256r1.c
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPBindGxyTblStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPBindGxyTblStd256r1
+//
+// Purpose: Enable the use of base point-based pre-computed
+// tables of standard elliptic curves for EC256r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPBindGxyTblStd256r1,(IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP256r1_fun();
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd384r1.c b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd384r1.c
new file mode 100644
index 0000000..9863acb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd384r1.c
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPBindGxyTblStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPBindGxyTblStd384r1
+//
+// Purpose: Enable the use of base point-based pre-computed
+// tables of standard elliptic curves for EC384r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPBindGxyTblStd384r1,(IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP384r1_fun();
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd521r1.c b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd521r1.c
new file mode 100644
index 0000000..eaf7a8c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpbindgxytblstd521r1.c
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPBindGxyTblStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPBindGxyTblStd521r1
+//
+// Purpose: Enable the use of base point-based pre-computed
+// tables of standard elliptic curves for EC521r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPBindGxyTblStd521r1,(IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP521r1_fun();
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpcheckpoint.c b/ext/ipp/sources/ippcp/pcpeccpcheckpoint.c
new file mode 100644
index 0000000..e96cdc6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpcheckpoint.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPCheckPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPCheckPoint
+//
+// Purpose: Check EC point:
+// - is point lie on EC
+// - is point at infinity
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pP
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pP->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPoint pointer to the EC Point context
+// pEC pointer to the ECCP context
+// pResult pointer to the result:
+// ippECValid
+// ippECPointIsNotValid
+// ippECPointIsAtInfinite
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP,
+ IppECResult* pResult,
+ IppsECCPState* pEC))
+{
+ return ippsGFpECTstPoint(pP, pResult, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpcomparepoint.c b/ext/ipp/sources/ippcp/pcpeccpcomparepoint.c
new file mode 100644
index 0000000..94e4973
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpcomparepoint.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPComparePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPComparePoint
+//
+// Purpose: Compare two EC points
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pP
+// NULL == pQ
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pP->idCtx
+// illegal pQ->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pP pointer to the EC Point context
+// pQ pointer to the EC Point context
+// pEC pointer to the EC context
+// pResult pointer to the result:
+// ippECPointIsEqual
+// ippECPointIsNotEqual
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP,
+ const IppsECCPPointState* pQ,
+ IppECResult* pResult,
+ IppsECCPState* pEC))
+{
+ return ippsGFpECCmpPoint(pP, pQ, pResult, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c b/ext/ipp/sources/ippcp/pcpeccpgenkeyca.c
index a301cea..615d4f8 100644
--- a/ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c
+++ b/ext/ipp/sources/ippcp/pcpeccpgenkeyca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -37,11 +61,11 @@
// Purpose: Generate (private,public) Key Pair
//
// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
+// ippStsNullPtrErr NULL == pEC
// NULL == pPrivate
// NULL == pPublic
//
-// ippStsContextMatchErr illegal pECC->idCtx
+// ippStsContextMatchErr illegal pEC->idCtx
// illegal pPrivate->idCtx
// illegal pPublic->idCtx
//
@@ -50,7 +74,9 @@
// Parameters:
// pPrivate pointer to the resultant private key
// pPublic pointer to the resultant public key
-// pECC pointer to the ECCP context
+// pEC pointer to the ECCP context
+// rndFunc Specified Random Generator.
+// pRndParam Pointer to the Random Generator context.
//
*F*/
IPPFUN(IppStatus, ippsECCPGenKeyPair, (IppsBigNumState* pPrivate, IppsECCPPointState* pPublic,
diff --git a/ext/ipp/sources/ippcp/pcpeccpget.c b/ext/ipp/sources/ippcp/pcpeccpget.c
new file mode 100644
index 0000000..48be3d4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpget.c
@@ -0,0 +1,172 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPGet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGet
+//
+// Purpose: Retrieve ECC Domain Parameter.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pPrime
+// NULL == pA
+// NULL == pB
+// NULL == pGX
+// NULL == pGY
+// NULL == pOrder
+// NULL == cofactor
+// NULL == pEC
+//
+// ippStsContextMatchErr illegal pPrime->idCtx
+// illegal pA->idCtx
+// illegal pB->idCtx
+// illegal pGX->idCtx
+// illegal pGY->idCtx
+// illegal pOrder->idCtx
+// illegal pEC->idCtx
+//
+// ippStsRangeErr not enough room for:
+// pPrime
+// pA, pB,
+// pGX,pGY
+// pOrder
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrime pointer to the retrieval prime (specify FG(p))
+// pA pointer to the retrieval A coefficient of EC equation
+// pB pointer to the retrieval B coefficient of EC equation
+// pGX,pGY pointer to the retrieval Base Point (x and y coordinates) of EC
+// pOrder pointer to the retrieval Base Point order
+// cofactor pointer to the retrieval cofactor value
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPGet, (IppsBigNumState* pPrime,
+ IppsBigNumState* pA, IppsBigNumState* pB,
+ IppsBigNumState* pGX,IppsBigNumState* pGY,
+ IppsBigNumState* pOrder, int* cofactor,
+ IppsECCPState* pEC))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ /* test pPrime */
+ IPP_BAD_PTR1_RET(pPrime);
+ pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_ROOM(pPrime)<GFP_FELEN(pGFE), ippStsRangeErr);
+
+ /* test pA and pB */
+ IPP_BAD_PTR2_RET(pA,pB);
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) );
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_ROOM(pA)<GFP_FELEN(pGFE), ippStsRangeErr);
+ IPP_BADARG_RET(BN_ROOM(pB)<GFP_FELEN(pGFE), ippStsRangeErr);
+
+ /* test pG and pGorder pointers */
+ IPP_BAD_PTR3_RET(pGX,pGY, pOrder);
+ pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) );
+ pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) );
+ pOrder= (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder,ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_ROOM(pGX)<GFP_FELEN(pGFE), ippStsRangeErr);
+ IPP_BADARG_RET(BN_ROOM(pGY)<GFP_FELEN(pGFE), ippStsRangeErr);
+ IPP_BADARG_RET((BN_ROOM(pOrder)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ /* test cofactor */
+ IPP_BAD_PTR1_RET(cofactor);
+
+ {
+ mod_decode decode = GFP_METHOD(pGFE)->decode; /* gf decode method */
+ BNU_CHUNK_T* tmp = cpGFpGetPool(1, pGFE);
+
+ /* retrieve EC parameter */
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)GFP_MODULUS(pGFE), pPrime);
+
+ decode(tmp, ECP_A(pEC), pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pA);
+ decode(tmp, ECP_B(pEC), pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pB);
+
+ decode(tmp, ECP_G(pEC), pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pGX);
+ decode(tmp, ECP_G(pEC)+GFP_FELEN(pGFE), pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pGY);
+
+ {
+ gsModEngine* pR = ECP_MONT_R(pEC);
+ ippsSet_BN(ippBigNumPOS, MOD_LEN(pR)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), (Ipp32u*)MOD_MODULUS(pR), pOrder);
+ }
+
+ *cofactor = (int)ECP_COFACTOR(pEC)[0];
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetorderbitsize.c b/ext/ipp/sources/ippcp/pcpeccpgetorderbitsize.c
new file mode 100644
index 0000000..be48546
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetorderbitsize.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPGetOrderBitSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetOrderBitSize
+//
+// Purpose: Retrieve size of Base Point Order (in bits).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pBitSize
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBitSize pointer to the size of base point order
+// pEC pointer to the EC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test pBitSize*/
+ IPP_BAD_PTR1_RET(pBitSize);
+
+ *pBitSize = ECP_ORDBITSIZE(pEC);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetpoint.c b/ext/ipp/sources/ippcp/pcpeccpgetpoint.c
new file mode 100644
index 0000000..e7a6a95
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetpoint.c
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPGetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetPoint
+//
+// Purpose: Converts internal presentation EC point - montgomery projective
+// into regular affine coordinates EC point (pX,pY)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPoint
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPoint->idCtx
+// NULL != pX, illegal pX->idCtx
+// NULL != pY, illegal pY->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pX pointer to the regular affine coordinate X
+// pY pointer to the regular affine coordinate Y
+// pPoint pointer to the EC Point context
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, IppsBigNumState* pY,
+ const IppsECCPPointState* pPoint,
+ IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test pX and pY */
+ if(pX) {
+ pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
+ }
+ if(pY) {
+ pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
+ }
+
+ {
+ IppStatus sts;
+
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_decode decode = GFP_METHOD(pGFE)->decode; /* gf decode method */
+
+ IppsGFpElement elmX, elmY;
+
+ cpGFpElementConstruct(&elmX, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmY, cpGFpGetPool(1, pGFE), elemLen);
+ do {
+ sts = ippsGFpECGetPoint(pPoint, pX? &elmX:NULL, pY? &elmY:NULL, pEC);
+ if(ippStsNoErr!=sts) break;
+
+ if(pX) {
+ decode(elmX.pData, elmX.pData, pGFE);
+ sts = ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)elmX.pData, pX);
+ if(ippStsNoErr!=sts) break;
+ }
+ if(pY) {
+ decode(elmY.pData, elmY.pData, pGFE);
+ sts = ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)elmY.pData, pY);
+ if(ippStsNoErr!=sts) break;
+ }
+ } while(0);
+
+ cpGFpReleasePool(2, pGFE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsize.c b/ext/ipp/sources/ippcp/pcpeccpgetsize.c
new file mode 100644
index 0000000..9471d7d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsize.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSize
+//
+// Purpose: Returns size of ECC context (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsSizeErr 2 > feBitSize
+// feBitSize > EC_GFP_MAXBITSIZE
+// ippStsNoErr no errors
+//
+// Parameters:
+// feBitSize size of field element (bits)
+// pSize pointer to the size of internal ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPGetSize, (int feBitSize, int *pSize))
+{
+ /* test size's pointer */
+ IPP_BAD_PTR1_RET(pSize);
+
+ /* test size of field element */
+ IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
+
+ {
+ /* size of GF context */
+ //int gfCtxSize = cpGFpGetSize(feBitSize);
+ int gfCtxSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
+ /* size of EC context */
+ int ecCtxSize = cpGFpECGetSize(1, feBitSize);
+
+ /* size of EC scratch buffer: 16 points of BITS_BNU_CHUNK(feBitSize)*3 length each */
+ int ecScratchBufferSize = 16*(BITS_BNU_CHUNK(feBitSize)*3)*sizeof(BNU_CHUNK_T);
+
+ *pSize = ecCtxSize /* EC context */
+ +ECGFP_ALIGNMENT
+ +gfCtxSize /* GF context */
+ +GFP_ALIGNMENT
+ +ecScratchBufferSize /* *scratch buffer */
+ +ecScratchBufferSize /* should be enough for 2 tables */
+ +CACHE_LINE_SIZE;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r1.c
new file mode 100644
index 0000000..a975a9b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r1.c
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd128r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd128r1
+//
+// Purpose: Returns size of ECC context for secp128r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+IPPFUN(IppStatus, ippsECCPGetSizeStd128r1, (int *pSize))
+{
+ return ippsECCPGetSize(128, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r2.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r2.c
new file mode 100644
index 0000000..4ad9037
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd128r2.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd128r2()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd128r2
+//
+// Purpose: Returns size of ECC context for secp128r2 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd128r2, (int *pSize))
+{
+ return ippsECCPGetSize(128, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd192r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd192r1.c
new file mode 100644
index 0000000..aee433f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd192r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd192r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd192r1
+//
+// Purpose: Returns size of ECC context for secp192r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd192r1, (int *pSize))
+{
+ return ippsECCPGetSize(192, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd224r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd224r1.c
new file mode 100644
index 0000000..39acd6e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd224r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd224r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd224r1
+//
+// Purpose: Returns size of ECC context for secp224r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd224r1, (int *pSize))
+{
+ return ippsECCPGetSize(224, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd256r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd256r1.c
new file mode 100644
index 0000000..63d1b6a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd256r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd256r1
+//
+// Purpose: Returns size of ECC context for secp256r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd256r1, (int *pSize))
+{
+ return ippsECCPGetSize(256, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd384r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd384r1.c
new file mode 100644
index 0000000..5029cc4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd384r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd384r1
+//
+// Purpose: Returns size of ECC context for secp384r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd384r1, (int *pSize))
+{
+ return ippsECCPGetSize(384, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpgetsizestd521r1.c b/ext/ipp/sources/ippcp/pcpeccpgetsizestd521r1.c
new file mode 100644
index 0000000..7edb715
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpgetsizestd521r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPGetSizeStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPGetSizeStd521r1
+//
+// Purpose: Returns size of ECC context for secp521r1 [SEC2] (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to the size of internal ECC context
+*F*/
+
+IPPFUN(IppStatus, ippsECCPGetSizeStd521r1, (int *pSize))
+{
+ return ippsECCPGetSize(521, pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinit.c b/ext/ipp/sources/ippcp/pcpeccpinit.c
new file mode 100644
index 0000000..7d2b16f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinit.c
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInit
+//
+// Purpose: Init ECC context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsSizeErr 2>feBitSize
+// feBitSize>EC_GFP_MAXBITSIZE
+// ippStsNoErr no errors
+//
+// Parameters:
+// feBitSize size of field element (bits)
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInit, (int feBitSize, IppsECCPState* pEC))
+{
+ /* test pEC pointer */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsECCPState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* test size of field element */
+ IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
+
+ {
+ /* size of GF context */
+ //int gfCtxSize = cpGFpGetSize(feBitSize);
+ int gfCtxSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
+ /* size of EC context */
+ int ecCtxSize = cpGFpECGetSize(1, feBitSize);
+
+ IppsGFpState* pGF = (IppsGFpState*)(IPP_ALIGNED_PTR((Ipp8u*)pEC+ecCtxSize, GFP_ALIGNMENT));
+ BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)IPP_ALIGNED_PTR((Ipp8u*)pGF+gfCtxSize, CACHE_LINE_SIZE);
+
+ /* set up contexts */
+ IppStatus sts;
+ do {
+ sts = cpGFpInitGFp(feBitSize, pGF);
+ if(ippStsNoErr!=sts) break;
+ sts = ippsGFpECInit(pGF, NULL, NULL, pEC);
+ } while (0);
+
+ /* save scratch buffer pointer */
+ ECP_SBUFFER(pEC) = pScratchBuffer;
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd128r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd128r1.c
new file mode 100644
index 0000000..48499db
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd128r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd128r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd128r1
+//
+// Purpose: Init ECC context for secp128r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd128r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(128, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd128r2.c b/ext/ipp/sources/ippcp/pcpeccpinitstd128r2.c
new file mode 100644
index 0000000..0385eb9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd128r2.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd128r2()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd128r2
+//
+// Purpose: Init ECC context for secp128r2 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd128r2, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(128, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd192r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd192r1.c
new file mode 100644
index 0000000..685aaf5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd192r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd192r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd192r1
+//
+// Purpose: Init ECC context for secp192r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd192r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(192, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd224r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd224r1.c
new file mode 100644
index 0000000..f34d4ab
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd224r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd224r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd224r1
+//
+// Purpose: Init ECC context for secp224r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd224r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(224, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd256r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd256r1.c
new file mode 100644
index 0000000..af83f7b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd256r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd256r1
+//
+// Purpose: Init ECC context for secp256r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd256r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(256, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd384r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd384r1.c
new file mode 100644
index 0000000..d4b7016
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd384r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd384r1
+//
+// Purpose: Init ECC context for secp384r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd384r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(384, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpinitstd521r1.c b/ext/ipp/sources/ippcp/pcpeccpinitstd521r1.c
new file mode 100644
index 0000000..32f38f6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpinitstd521r1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (initialization)
+//
+// Contents:
+// ippsECCPInitStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStd521r1
+//
+// Purpose: Init ECC context for secp521r1 [SEC2].
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pECC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pECC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPInitStd521r1, (IppsECCPState* pEC))
+{
+ return ippsECCPInit(521, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpmulpointscalar.c b/ext/ipp/sources/ippcp/pcpeccpmulpointscalar.c
new file mode 100644
index 0000000..7a93cae
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpmulpointscalar.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPMulPointScalar()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPMulPointScalar
+//
+// Purpose: Perforn EC point operation: R = k*P
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pP
+// NULL == pK
+// NULL == pR
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pP->idCtx
+// illegal pK->idCtx
+// illegal pR->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pP pointer to the source EC Point context
+// pK pointer to the source BigNum multiplier context
+// pR pointer to the resultant EC Point context
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP,
+ const IppsBigNumState* pK,
+ IppsECCPPointState* pR,
+ IppsECCPState* pEC))
+{
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECMulPoint(pP, pK, pR, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpnegativepoint.c b/ext/ipp/sources/ippcp/pcpeccpnegativepoint.c
new file mode 100644
index 0000000..733e900
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpnegativepoint.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPNegativePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPNegativePoint
+//
+// Purpose: Perforn EC point operation: R = -P
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pP
+// NULL == pR
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pP->idCtx
+// illegal pR->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pP pointer to the source EC Point context
+// pR pointer to the resultant EC Point context
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPNegativePoint, (const IppsECCPPointState* pP,
+ IppsECCPPointState* pR,
+ IppsECCPState* pEC))
+{
+ return ippsGFpECNegPoint(pP, pR, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccppointgetsize.c b/ext/ipp/sources/ippcp/pcpeccppointgetsize.c
new file mode 100644
index 0000000..c21a7bc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccppointgetsize.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC (prime) Point
+//
+// Contents:
+// ippsECCPPointGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPPointGetSize
+//
+// Purpose: Returns size of EC Point context (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSzie
+// ippStsSizeErr 2>feBitSize
+// ippStsNoErr no errors
+//
+// Parameters:
+// feBitSize size of field element (bits)
+// pSize pointer to the size of EC Point context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPPointGetSize, (int feBitSize, int* pSize))
+{
+ /* test size's pointer */
+ IPP_BAD_PTR1_RET(pSize);
+
+ /* test size of field element */
+ IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
+
+ {
+ int elemLen = BITS_BNU_CHUNK(feBitSize);
+ *pSize= sizeof(IppsGFpECPoint)
+ +elemLen*sizeof(BNU_CHUNK_T) /* X */
+ +elemLen*sizeof(BNU_CHUNK_T) /* Y */
+ +elemLen*sizeof(BNU_CHUNK_T);/* Z */
+ }
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccppointinit.c b/ext/ipp/sources/ippcp/pcpeccppointinit.c
new file mode 100644
index 0000000..b2e210e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccppointinit.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC (prime) Point
+//
+// Contents:
+// ippsECCPPointInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPPointInit
+//
+// Purpose: Init EC Point context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pPoint
+// ippStsSizeErr 2>feBitSize
+// ippStsNoErr no errors
+//
+// Parameters:
+// feBitSize size of field element (bits)
+// pECC pointer to ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPPointInit, (int feBitSize, IppsECCPPointState* pPoint))
+{
+ /* test pEC pointer */
+ IPP_BAD_PTR1_RET(pPoint);
+
+ /* test size of field element */
+ IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
+
+ {
+ int elemLen = BITS_BNU_CHUNK(feBitSize);
+ Ipp8u* ptr = (Ipp8u*)pPoint;
+
+ ECP_POINT_ID(pPoint) = idCtxGFPPoint;
+ ECP_POINT_FLAGS(pPoint) = 0;
+ ECP_POINT_FELEN(pPoint) = elemLen;
+ ptr += sizeof(IppsGFpECPoint);
+ ECP_POINT_DATA(pPoint) = (BNU_CHUNK_T*)(ptr);
+
+ gfec_SetPointAtInfinity(pPoint);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccppublickeyca.c b/ext/ipp/sources/ippcp/pcpeccppublickeyca.c
new file mode 100644
index 0000000..20bfd7f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccppublickeyca.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Key Generation)
+//
+// Contents:
+// ippsECCPPublicKey()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPPublicKey
+//
+// Purpose: Calculate Public Key
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivate
+// NULL == pPublic
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPrivate->idCtx
+// illegal pPublic->idCtx
+//
+// ippStsIvalidPrivateKey !(0 < pPrivate < order)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivate pointer to the private key
+// pPublic pointer to the resultant public key
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPPublicKey, (const IppsBigNumState* pPrivate,
+ IppsECCPPointState* pPublic,
+ IppsECCPState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECPublicKey(pPrivate, pPublic, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsecretdhca.c b/ext/ipp/sources/ippcp/pcpeccpsecretdhca.c
new file mode 100644
index 0000000..91e5744
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsecretdhca.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Key Ecxhange, Diffie-Hellman version)
+//
+// Contents:
+// ippsECCPSharedSecretDH()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPSharedSecretDH
+//
+// Purpose: Shared Secret Value Derivation
+// (Diffie-Hellman version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivateA
+// NULL == pPublicB
+// NULL == pShare
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPrivateA->idCtx
+// illegal pPublicB->idCtx
+// illegal pShare->idCtx
+//
+// ippStsRangeErr not enough room for share key
+//
+// ippStsShareKeyErr (infinity) => z
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivateA pointer to own private key
+// pPublicB pointer to alien public key
+// pShare pointer to the shareds secret value
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA,
+ const IppsECCPPointState* pPublicB,
+ IppsBigNumState* pShare,
+ IppsECCPState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECSharedSecretDH(pPrivateA, pPublicB, pShare, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsecretdhcca.c b/ext/ipp/sources/ippcp/pcpeccpsecretdhcca.c
new file mode 100644
index 0000000..cf40175
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsecretdhcca.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Key Ecxhange, Diffie-Hellman version with cofactor)
+//
+// Contents:
+// ippsECCPSharedSecretDHC()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPSharedSecretDHC
+//
+// Purpose: Shared Secret Value Derivation
+// (Diffie-Hellman version with cofactor).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivateA
+// NULL == pPublicB
+// NULL == pShare
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPrivateA->idCtx
+// illegal pPublicB->idCtx
+// illegal pShare->idCtx
+//
+// ippStsRangeErr not enough room for share key
+//
+// ippStsShareKeyErr (infinity) => z
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivateA pointer to own private key
+// pPublicB pointer to alien public key
+// pShare pointer to the shared secret value
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSharedSecretDHC,(const IppsBigNumState* pPrivateA,
+ const IppsECCPPointState* pPublicB,
+ IppsBigNumState* pShare,
+ IppsECCPState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECSharedSecretDHC(pPrivateA, pPublicB, pShare, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpset.c b/ext/ipp/sources/ippcp/pcpeccpset.c
new file mode 100644
index 0000000..29cb438
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpset.c
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPInitStdSM2
+//
+// Purpose: Sets up the elliptic curve domain parameters
+// over a prime finite field GF(p)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pPrime
+// NULL == pA
+// NULL == pB
+// NULL == pGX
+// NULL == pGY
+// NULL == pOrder
+// NULL == cofactor
+// NULL == pEC
+//
+// ippStsContextMatchErr illegal pPrime->idCtx
+// illegal pA->idCtx
+// illegal pB->idCtx
+// illegal pGX->idCtx
+// illegal pGY->idCtx
+// illegal pOrder->idCtx
+// illegal pEC->idCtx
+//
+// ippStsRangeErr not enough room for:
+// pPrime
+// pA, pB,
+// pGX, pGY
+// pOrder
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrime pointer to the retrieval prime (specify FG(p))
+// pA pointer to the retrieval A coefficient of EC equation
+// pB pointer to the retrieval B coefficient of EC equation
+// pGX,pGY pointer to the retrieval Base Point (x and y coordinates) of EC
+// pOrder pointer to the retrieval Base Point order
+// cofactor pointer to the retrieval cofactor value
+// pEC pointer to the ECC context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsECCPSet, (const IppsBigNumState* pPrime,
+ const IppsBigNumState* pA, const IppsBigNumState* pB,
+ const IppsBigNumState* pGX,const IppsBigNumState* pGY,
+ const IppsBigNumState* pOrder, int cofactor,
+ IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test pPrime */
+ IPP_BAD_PTR1_RET(pPrime);
+ pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
+ IPP_BADARG_RET((cpBN_bitsize(pPrime)>GFP_FEBITLEN(GFP_PMA(ECP_GFP(pEC)))), ippStsRangeErr);
+
+ /* test pA and pB */
+ IPP_BAD_PTR2_RET(pA,pB);
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) );
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pA) || 0<=cpBN_cmp(pA,pPrime), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pB) || 0<=cpBN_cmp(pB,pPrime), ippStsRangeErr);
+
+ /* test pG and pGorder pointers */
+ IPP_BAD_PTR3_RET(pGX,pGY, pOrder);
+ pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) );
+ pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) );
+ pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pGX) || 0<=cpBN_cmp(pGX,pPrime), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pGY) || 0<=cpBN_cmp(pGY,pPrime), ippStsRangeErr);
+ IPP_BADARG_RET((cpBN_bitsize(pOrder)>ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ /* test cofactor */
+ IPP_BADARG_RET(!(0<cofactor), ippStsRangeErr);
+
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BN_SIZE(pPrime), BN_NUMBER(pPrime),
+ BN_SIZE(pA), BN_NUMBER(pA),
+ BN_SIZE(pB), BN_NUMBER(pB),
+ BN_SIZE(pGX), BN_NUMBER(pGX),
+ BN_SIZE(pGY), BN_NUMBER(pGY),
+ BN_SIZE(pOrder), BN_NUMBER(pOrder),
+ (BNU_CHUNK_T)cofactor,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c b/ext/ipp/sources/ippcp/pcpeccpsetkeyca.c
index e761e29..571a5da 100644
--- a/ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c
+++ b/ext/ipp/sources/ippcp/pcpeccpsetkeyca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -37,11 +61,11 @@
// Purpose: Generate (private,public) Key Pair
//
// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
+// ippStsNullPtrErr NULL == pEC
// NULL == pPrivate
// NULL == pPublic
//
-// ippStsContextMatchErr illegal pECC->idCtx
+// ippStsContextMatchErr illegal pEC->idCtx
// illegal pPrivate->idCtx
// illegal pPublic->idCtx
//
@@ -51,7 +75,7 @@
// pPrivate pointer to the private key
// pPublic pointer to the public key
// regular flag regular/ephemeral keys
-// pECC pointer to the ECCP context
+// pEC pointer to the ECCP context
//
*F*/
IPPFUN(IppStatus, ippsECCPSetKeyPair, (const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic,
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetpoint.c b/ext/ipp/sources/ippcp/pcpeccpsetpoint.c
new file mode 100644
index 0000000..5bc4a52
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetpoint.c
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPSetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetPoint
+//
+// Purpose: Converts regular affine coordinates EC point (pX,pY)
+// into internal presentation - montgomery projective.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPoint
+// NULL == pX
+// NULL == pY
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pX->idCtx
+// illegal pY->idCtx
+// illegal pPoint->idCtx
+//
+// ippStsOutOfECErr point out-of EC
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pX pointer to the regular affine coordinate X
+// pY pointer to the regular affine coordinate Y
+// pPoint pointer to the EC Point context
+// pEC pointer to the ECCP context
+//
+// Note:
+// if B==0 and (x,y)=(0,y) then point at Infinity will be set up
+// if B!=0 and (x,y)=(0,0) then point at Infinity will be set up
+// else point with requested coordinates (x,y) wil be set up
+// There are no check validation inside!
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX,
+ const IppsBigNumState* pY,
+ IppsECCPPointState* pPoint,
+ IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test pX and pY */
+ IPP_BAD_PTR2_RET(pX,pY);
+ pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
+ pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
+
+ {
+ IppStatus sts;
+
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+ IppsGFpElement elmX, elmY;
+
+ cpGFpElementConstruct(&elmX, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmY, cpGFpGetPool(1, pGFE), elemLen);
+ do {
+ BNU_CHUNK_T* pData = BN_NUMBER(pX);
+ int ns = BN_SIZE(pX);
+ sts = ippsGFpSetElement((Ipp32u*)pData, BITS2WORD32_SIZE(BITSIZE_BNU(pData, ns)), &elmX, pGF);
+ if(ippStsNoErr!=sts) break;
+ pData = BN_NUMBER(pY);
+ ns = BN_SIZE(pY);
+ sts = ippsGFpSetElement((Ipp32u*)pData, BITS2WORD32_SIZE(BITSIZE_BNU(pData, ns)), &elmY, pGF);
+ if(ippStsNoErr!=sts) break;
+ sts = ippsGFpECSetPoint(&elmX, &elmY, pPoint, pEC);
+ } while(0);
+
+ cpGFpReleasePool(2, pGFE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetpointatinfinity.c b/ext/ipp/sources/ippcp/pcpeccpsetpointatinfinity.c
new file mode 100644
index 0000000..9dd82fa
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetpointatinfinity.c
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Point operations)
+//
+// Contents:
+// ippsECCPSetPointAtInfinity()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetPointAtInfinity
+//
+// Purpose: Set point at Infinity
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPoint
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPoint->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPoint pointer to the EC Point context
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pEC))
+{
+ return ippsGFpECSetPointAtInfinity(pPoint, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd.c b/ext/ipp/sources/ippcp/pcpeccpsetstd.c
new file mode 100644
index 0000000..dbbe7a0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd.c
@@ -0,0 +1,152 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd
+//
+// Purpose: Set Standard ECC Domain Parameter.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsECCInvalidFlagErr invalid flag
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// flag specify standard ECC parameter(s) to be setup
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd, (IppECCType flag, IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ switch(flag) {
+ case IppECCPStd112r1:
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(112), secp112r1_p,
+ BITS_BNU_CHUNK(112), secp112r1_a,
+ BITS_BNU_CHUNK(112), secp112r1_b,
+ BITS_BNU_CHUNK(112), secp112r1_gx,
+ BITS_BNU_CHUNK(112), secp112r1_gy,
+ BITS_BNU_CHUNK(112), secp112r1_r,
+ secp112r1_h, pEC);
+
+ case IppECCPStd112r2:
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(112), secp112r2_p,
+ BITS_BNU_CHUNK(112), secp112r2_a,
+ BITS_BNU_CHUNK(112), secp112r2_b,
+ BITS_BNU_CHUNK(112), secp112r2_gx,
+ BITS_BNU_CHUNK(112), secp112r2_gy,
+ BITS_BNU_CHUNK(112), secp112r2_r,
+ secp112r2_h, pEC);
+
+ case IppECCPStd128r1: return ippsECCPSetStd128r1(pEC);
+
+ case IppECCPStd128r2: return ippsECCPSetStd128r2(pEC);
+
+ case IppECCPStd160r1:
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(160), secp160r1_p,
+ BITS_BNU_CHUNK(160), secp160r1_a,
+ BITS_BNU_CHUNK(160), secp160r1_b,
+ BITS_BNU_CHUNK(160), secp160r1_gx,
+ BITS_BNU_CHUNK(160), secp160r1_gy,
+ BITS_BNU_CHUNK(161), secp160r1_r,
+ secp160r1_h, pEC);
+
+ case IppECCPStd160r2:
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(160), secp160r2_p,
+ BITS_BNU_CHUNK(160), secp160r2_a,
+ BITS_BNU_CHUNK(160), secp160r2_b,
+ BITS_BNU_CHUNK(160), secp160r2_gx,
+ BITS_BNU_CHUNK(160), secp160r2_gy,
+ BITS_BNU_CHUNK(161), secp160r2_r,
+ secp160r2_h, pEC);
+
+ case IppECCPStd192r1: return ippsECCPSetStd192r1(pEC);
+
+ case IppECCPStd224r1: return ippsECCPSetStd224r1(pEC);
+
+ case IppECCPStd256r1: return ippsECCPSetStd256r1(pEC);
+
+ case IppECCPStd384r1: return ippsECCPSetStd384r1(pEC);
+
+ case IppECCPStd521r1: return ippsECCPSetStd521r1(pEC);
+
+ case ippEC_TPM_BN_P256:
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(256), tpmBN_p256p_p,
+ BITS_BNU_CHUNK(32), tpmBN_p256p_a,
+ BITS_BNU_CHUNK(32), tpmBN_p256p_b,
+ BITS_BNU_CHUNK(32), tpmBN_p256p_gx,
+ BITS_BNU_CHUNK(32), tpmBN_p256p_gy,
+ BITS_BNU_CHUNK(256), tpmBN_p256p_r,
+ tpmBN_p256p_h, pEC);
+
+ //case ippECPstdSM2: return ippsECCPSetStdSM2(pEC);
+
+ default:
+ return ippStsECCInvalidFlagErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd128r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd128r1.c
new file mode 100644
index 0000000..b09adbd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd128r1.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd128r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd128r1
+//
+// Purpose: Set EC128r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd128r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(128), secp128r1_p,
+ BITS_BNU_CHUNK(128), secp128r1_a,
+ BITS_BNU_CHUNK(128), secp128r1_b,
+ BITS_BNU_CHUNK(128), secp128r1_gx,
+ BITS_BNU_CHUNK(128), secp128r1_gy,
+ BITS_BNU_CHUNK(128), secp128r1_r,
+ secp128r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd128r2.c b/ext/ipp/sources/ippcp/pcpeccpsetstd128r2.c
new file mode 100644
index 0000000..08165ca
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd128r2.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd128r2()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd128r2
+//
+// Purpose: Set EC128r2 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd128r2, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_pArb(),
+ BITS_BNU_CHUNK(128), secp128r2_p,
+ BITS_BNU_CHUNK(128), secp128r2_a,
+ BITS_BNU_CHUNK(128), secp128r2_b,
+ BITS_BNU_CHUNK(128), secp128r2_gx,
+ BITS_BNU_CHUNK(128), secp128r2_gy,
+ BITS_BNU_CHUNK(128), secp128r2_r,
+ secp128r2_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd192r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd192r1.c
new file mode 100644
index 0000000..22202b5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd192r1.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd192r1()
+//
+*/
+
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd192r1
+//
+// Purpose: Set EC192r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd192r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_p192r1(),
+ BITS_BNU_CHUNK(192), secp192r1_p,
+ BITS_BNU_CHUNK(192), secp192r1_a,
+ BITS_BNU_CHUNK(192), secp192r1_b,
+ BITS_BNU_CHUNK(192), secp192r1_gx,
+ BITS_BNU_CHUNK(192), secp192r1_gy,
+ BITS_BNU_CHUNK(192), secp192r1_r,
+ secp192r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd224r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd224r1.c
new file mode 100644
index 0000000..11d5f38
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd224r1.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd224r1()
+//
+*/
+
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd224r1
+//
+// Purpose: Set EC224r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd224r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsECCPState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_p224r1(),
+ BITS_BNU_CHUNK(224), secp224r1_p,
+ BITS_BNU_CHUNK(224), secp224r1_a,
+ BITS_BNU_CHUNK(224), secp224r1_b,
+ BITS_BNU_CHUNK(224), secp224r1_gx,
+ BITS_BNU_CHUNK(224), secp224r1_gy,
+ BITS_BNU_CHUNK(224), secp224r1_r,
+ secp224r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd256r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd256r1.c
new file mode 100644
index 0000000..9a7208d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd256r1.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd256r1
+//
+// Purpose: Set EC256r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd256r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_p256r1(),
+ BITS_BNU_CHUNK(256), secp256r1_p,
+ BITS_BNU_CHUNK(256), secp256r1_a,
+ BITS_BNU_CHUNK(256), secp256r1_b,
+ BITS_BNU_CHUNK(256), secp256r1_gx,
+ BITS_BNU_CHUNK(256), secp256r1_gy,
+ BITS_BNU_CHUNK(256), secp256r1_r,
+ secp256r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd384r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd384r1.c
new file mode 100644
index 0000000..d52ef52
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd384r1.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd384r1
+//
+// Purpose: Set EC384r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd384r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_p384r1(),
+ BITS_BNU_CHUNK(384), secp384r1_p,
+ BITS_BNU_CHUNK(384), secp384r1_a,
+ BITS_BNU_CHUNK(384), secp384r1_b,
+ BITS_BNU_CHUNK(384), secp384r1_gx,
+ BITS_BNU_CHUNK(384), secp384r1_gy,
+ BITS_BNU_CHUNK(384), secp384r1_r,
+ secp384r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsetstd521r1.c b/ext/ipp/sources/ippcp/pcpeccpsetstd521r1.c
new file mode 100644
index 0000000..7a2961b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsetstd521r1.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (setup/retrieve domain parameters)
+//
+// Contents:
+// ippsECCPSetStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsECCPSetStd521r1
+//
+// Purpose: Set EC521r1 parameters
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pEC pointer to the ECC context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSetStd521r1, (IppsECCPState* pEC))
+{
+ /* test pEC */
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ /* set domain parameters */
+ return ECCPSetDP(ippsGFpMethod_p521r1(),
+ BITS_BNU_CHUNK(521), secp521r1_p,
+ BITS_BNU_CHUNK(521), secp521r1_a,
+ BITS_BNU_CHUNK(521), secp521r1_b,
+ BITS_BNU_CHUNK(521), secp521r1_gx,
+ BITS_BNU_CHUNK(521), secp521r1_gy,
+ BITS_BNU_CHUNK(521), secp521r1_r,
+ secp521r1_h,
+ pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsigndsaca.c b/ext/ipp/sources/ippcp/pcpeccpsigndsaca.c
new file mode 100644
index 0000000..91a9dbe
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsigndsaca.c
@@ -0,0 +1,221 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (Sign, DSA version)
+//
+// Contents:
+// ippsECCPSignDSA()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPSignDSA
+//
+// Purpose: Signing of message representative.
+// (DSA version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pPrivate
+// NULL == pSignX
+// NULL == pSignY
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pMsgDigest->idCtx
+// illegal pPrivate->idCtx
+// illegal pSignX->idCtx
+// illegal pSignY->idCtx
+//
+// ippStsIvalidPrivateKey 0 >= Private
+// Private >= order
+//
+// ippStsMessageErr MsgDigest >= order
+// MsgDigest < 0
+//
+// ippStsRangeErr not enough room for:
+// signX
+// signY
+//
+// ippStsEphemeralKeyErr (0==signX) || (0==signY)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pPrivate pointer to the regular private key
+// pSignX,pSignY pointer to the signature
+// pEC pointer to the ECCP context
+//
+// Note:
+// - ephemeral key pair extracted from pEC and
+// must be generated and before ippsECCPDSASign() usage
+// - ephemeral key pair destroy before exit
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pPrivate,
+ IppsBigNumState* pSignX, IppsBigNumState* pSignY,
+ IppsECCPState* pEC))
+{
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test private key*/
+ IPP_BAD_PTR1_RET(pPrivate);
+ pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pPrivate), ippStsIvalidPrivateKey);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignX,pSignY);
+ pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, BN_ALIGNMENT) );
+ pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pSignX)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+ IPP_BADARG_RET((BN_ROOM(pSignY)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ {
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int ordLen = MOD_LEN(pMontR);
+
+ BNU_CHUNK_T* pPriData = BN_NUMBER(pPrivate);
+ int priLen = BN_SIZE(pPrivate);
+
+ BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
+ int msgLen = BN_SIZE(pMsgDigest);
+
+ /* make sure regular 0 < private < order */
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pPriData, priLen, 0) ||
+ 0<=cpCmp_BNU(pPriData, priLen, pOrder, ordLen), ippStsIvalidPrivateKey);
+ /* make sure msg <order */
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, ordLen), ippStsMessageErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pMontP = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pMontP);
+
+ BNU_CHUNK_T* dataC = BN_NUMBER(pSignX);
+ BNU_CHUNK_T* dataD = BN_NUMBER(pSignY);
+ BNU_CHUNK_T* buffF = BN_BUFFER(pSignX);
+ BNU_CHUNK_T* buffT = BN_BUFFER(pSignY);
+ int ns;
+
+ /* ephemeral public */
+ IppsGFpECPoint ephPublic;
+ cpEcGFpInitPoint(&ephPublic, ECP_PUBLIC_E(pEC), ECP_FINITE_POINT|ECP_AFFINE_POINT, pEC);
+
+ /*
+ // signX = int(ephPublic.x) (mod order)
+ */
+ {
+ BNU_CHUNK_T* buffer = gsModPoolAlloc(pMontP, 1);
+ gfec_GetPoint(buffer, NULL, &ephPublic, pEC);
+ GFP_METHOD(pMontP)->decode(buffer, buffer, pMontP);
+ ns = cpMod_BNU(buffer, elmLen, pOrder, ordLen);
+ cpGFpElementCopyPadd(dataC, ordLen, buffer, ns);
+ gsModPoolFree(pMontP, 1);
+ }
+
+ if(!GFP_IS_ZERO(dataC, ordLen)) {
+ /*
+ // signY = (1/ephPrivate)*(pMsgDigest + private*signX) (mod order)
+ */
+
+ /* copy and expand message is being signed */
+ ZEXPAND_COPY_BNU(buffF, ordLen, pMsgData, msgLen);
+
+ /* private representation in Montgomery domain */
+ ZEXPAND_COPY_BNU(dataD, ordLen, pPriData, priLen);
+ GFP_METHOD(pMontR)->encode(dataD, dataD, pMontR);
+
+ /* (private*signX) in regular domain */
+ GFP_METHOD(pMontR)->mul(dataD, dataD, dataC, pMontR);
+
+ /* pMsgDigest + private*signX */
+ cpModAdd_BNU(dataD, dataD, buffF, pOrder, ordLen, buffT);
+
+ if(!GFP_IS_ZERO(dataD, ordLen)) {
+ /* (1/ephPrivate) in Montgomery domain */
+ gs_mont_inv(buffT, ECP_PRIVAT_E(pEC), pMontR, alm_mont_inv_ct);
+
+ /* (1/ephPrivate)*(pMsgDigest + private*signX) */
+ GFP_METHOD(pMontR)->mul(dataD, dataD, buffT, pMontR);
+
+ /* signX */
+ ns = ordLen;
+ FIX_BNU(dataC, ns);
+ BN_SIGN(pSignX) = ippBigNumPOS;
+ BN_SIZE(pSignX) = ns;
+ /* signY */
+ ns = ordLen;
+ FIX_BNU(dataD, ns);
+ BN_SIGN(pSignY) = ippBigNumPOS;
+ BN_SIZE(pSignY) = ns;
+
+ return ippStsNoErr;
+ }
+ }
+
+ return ippStsEphemeralKeyErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsignnrca.c b/ext/ipp/sources/ippcp/pcpeccpsignnrca.c
new file mode 100644
index 0000000..0712871
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsignnrca.c
@@ -0,0 +1,205 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (Sign, NR version)
+//
+// Contents:
+// ippsECCPSignNR()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPSignNR
+//
+// Purpose: Signing of message representative.
+// (NR version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pPrivate
+// NULL == pSignX
+// NULL == pSignY
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pMsgDigest->idCtx
+// illegal pPrivate->idCtx
+// illegal pSignX->idCtx
+// illegal pSignY->idCtx
+//
+// ippStsIvalidPrivateKey 0 >= Private
+// Private >= order
+//
+// ippStsMessageErr MsgDigest >= order
+// MsgDigest < 0
+//
+// ippStsRangeErr not enough room for:
+// signX
+// signY
+//
+// ippStsEphemeralKeyErr (0==signX) || (0==signY)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pPrivate pointer to the regular private key
+// pSignX,pSignY pointer to the signature
+// pEC pointer to the ECCP context
+//
+// Note:
+// - ephemeral key pair extracted from pEC and
+// must be generated and before ippsECCPNRSign() usage
+// - ephemeral key pair destroy before exit
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSignNR,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pPrivate,
+ IppsBigNumState* pSignX, IppsBigNumState* pSignY,
+ IppsECCPState* pEC))
+{
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ /* test private key*/
+ IPP_BAD_PTR1_RET(pPrivate);
+ pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pPrivate), ippStsIvalidPrivateKey);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignX,pSignY);
+ pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) );
+ pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pSignX)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+ IPP_BADARG_RET((BN_ROOM(pSignY)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ {
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int ordLen = MOD_LEN(pMontR);
+
+ BNU_CHUNK_T* pPriData = BN_NUMBER(pPrivate);
+ int priLen = BN_SIZE(pPrivate);
+
+ BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
+ int msgLen = BN_SIZE(pMsgDigest);
+
+ /* make sure regular 0 < private < order */
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pPriData, priLen, 0) ||
+ 0<=cpCmp_BNU(pPriData, priLen, pOrder, ordLen), ippStsIvalidPrivateKey);
+ /* make sure msg <order */
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, ordLen), ippStsMessageErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pMontP = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pMontP);
+
+ BNU_CHUNK_T* dataC = BN_NUMBER(pSignX);
+ BNU_CHUNK_T* dataD = BN_NUMBER(pSignY);
+ BNU_CHUNK_T* buffF = BN_BUFFER(pSignX);
+ int ns;
+
+ /* ephemeral public */
+ IppsGFpECPoint ephPublic;
+ cpEcGFpInitPoint(&ephPublic, ECP_PUBLIC_E(pEC), ECP_FINITE_POINT|ECP_AFFINE_POINT, pEC);
+
+ /* ephPublic.x (mod order) */
+ {
+ BNU_CHUNK_T* buffer = gsModPoolAlloc(pMontP, 1);
+ gfec_GetPoint(buffer, NULL, &ephPublic, pEC);
+ GFP_METHOD(pMontP)->decode(buffer, buffer, pMontP);
+ ns = cpMod_BNU(buffer, elmLen, pOrder, ordLen);
+ cpGFpElementCopyPadd(dataC, ordLen, buffer, ns);
+ gsModPoolFree(pMontP, 1);
+ }
+
+ /* signX = (pMsgDigest + C) (mod order) */
+ ZEXPAND_COPY_BNU(buffF, ordLen, pMsgData, msgLen);
+ cpModAdd_BNU(dataC, dataC, buffF, pOrder, ordLen, dataD);
+
+ if(!GFP_IS_ZERO(dataC, ordLen)) {
+
+ /* signY = (eph_private - private*signX) (mod order) */
+ ZEXPAND_COPY_BNU(dataD, ordLen, pPriData, priLen);
+ GFP_METHOD(pMontR)->encode(dataD, dataD, pMontR);
+ GFP_METHOD(pMontR)->mul(dataD, dataD, dataC, pMontR);
+ cpModSub_BNU(dataD, ECP_PRIVAT_E(pEC), dataD, pOrder, ordLen, buffF);
+
+ /* signX */
+ ns = ordLen;
+ FIX_BNU(dataC, ns);
+ BN_SIGN(pSignX) = ippBigNumPOS;
+ BN_SIZE(pSignX) = ns;
+
+ /* signY */
+ ns = ordLen;
+ FIX_BNU(dataD, ns);
+ BN_SIGN(pSignY) = ippBigNumPOS;
+ BN_SIZE(pSignY) = ns;
+
+ return ippStsNoErr;
+ }
+
+ return ippStsEphemeralKeyErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpsignsm2ca.c b/ext/ipp/sources/ippcp/pcpeccpsignsm2ca.c
new file mode 100644
index 0000000..586956e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpsignsm2ca.c
@@ -0,0 +1,120 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (Sign, SM2 version)
+//
+// Contents:
+// ippsECCPSignSM2()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPSignSM2
+//
+// Purpose: Signing of message representative.
+// (SM2 version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPrivate
+// NULL == pEphPrivate
+// NULL == pSignR
+// NULL == pSignS
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pMsgDigest->idCtx
+// illegal pRegPrivate->idCtx
+// illegal pEphPrivate->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsIvalidPrivateKey (1 + regPrivate) >= order
+//
+// ippStsMessageErr MsgDigest >= order
+// MsgDigest < 0
+//
+// ippStsRangeErr not enough room for:
+// signR
+// signS
+//
+// ippStsEphemeralKeyErr (signR + ephPrivate) == order
+// (0==signR) || (0==signS)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pRegPrivate pointer to the regular private key
+// pEphPrivate pointer to the ephemeral private key
+// pSignR,pSignS pointer to the signature
+// pEC pointer to the ECCP context
+//
+// Note:
+// ephemeral key computes inside ippsECCPSignSM2 in contrast with ippsECCPSignDSA,
+// where ephemeral key pair computed before call and setup in context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPSignSM2,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pRegPrivate,
+ const IppsBigNumState* pEphPrivate,
+ IppsBigNumState* pSignR, IppsBigNumState* pSignS,
+ IppsECCPState* pEC))
+{
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECSignSM2(pMsgDigest,
+ pRegPrivate, pEphPrivate,
+ pSignR, pSignS,
+ pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpstdca.c b/ext/ipp/sources/ippcp/pcpeccpstdca.c
index c5c3320..b0d5dfe 100644
--- a/ext/ipp/sources/ippcp/src/pcpeccpstdca.c
+++ b/ext/ipp/sources/ippcp/pcpeccpstdca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/pcpeccpvalidateca.c b/ext/ipp/sources/ippcp/pcpeccpvalidateca.c
new file mode 100644
index 0000000..99d4023
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpvalidateca.c
@@ -0,0 +1,116 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (validate domain parameters)
+//
+// Contents:
+// ippsECCPValidate()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPValidate
+//
+// Purpose: Validate ECC Domain Parameters.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == c
+// NULL == pSeed
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal c->idCtx
+//
+// ippStsBadArgErr nTrials <=0
+// BN_SIZE(c)<5
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// nTrials number of trials of primality test
+// pResult pointer to the validation result
+// pEC pointer to the ECC context
+// rndFunc Specified Random Generator.
+// pRndParam Pointer to Random Generator context.
+//
+// Note
+// Validation Domain Parameters folowing by P1363 recommendation
+// (reference A.16.8)
+//
+*F*/
+
+#define _DISABLE_TEST_PRIMALITY_
+// validation has been reduced in comparison with legacy version:
+// - no primality test of underlying prime
+// - no primality test of base point order
+// - no MOV test
+
+IPPFUN(IppStatus, ippsECCPValidate, (int nTrials, IppECResult* pResult, IppsECCPState* pEC,
+ IppBitSupplier rndFunc, void* pRndParam))
+{
+ #if defined(_DISABLE_TEST_PRIMALITY_)
+ UNREFERENCED_PARAMETER(nTrials);
+ UNREFERENCED_PARAMETER(rndFunc);
+ UNREFERENCED_PARAMETER(pRndParam);
+ #else
+ /* test number of trials for primality check */
+ IPP_BADARG_RET(nTrials<=0, ippStsBadArgErr);
+ IPP_BAD_PTR2_RET(rndFunc, pRndParam);
+ #endif
+
+ IPP_BAD_PTR2_RET(pResult, pEC);
+
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECVerify(pResult, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpvalidatekeyca.c b/ext/ipp/sources/ippcp/pcpeccpvalidatekeyca.c
new file mode 100644
index 0000000..1535cac
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpvalidatekeyca.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (EC Key Generation)
+//
+// Contents:
+// ippsECCPValidateKeyPair()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPValidateKeyPair
+//
+// Purpose: Validate (private,public) Key Pair
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivate
+// NULL == pPublic
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pPrivate->idCtx
+// illegal pPublic->idCtx
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivate pointer to the private key
+// pPublic pointer to the public key
+// pResult pointer to the result:
+// ippECValid/ippECInvalidPrivateKey/ippECPointIsAtInfinite/ippECInvalidPublicKey
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPValidateKeyPair, (const IppsBigNumState* pPrivate,
+ const IppsECCPPointState* pPublic,
+ IppECResult* pResult,
+ IppsECCPState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ return ippsGFpECTstKeyPair(pPrivate, pPublic, pResult, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpverifydsaca.c b/ext/ipp/sources/ippcp/pcpeccpverifydsaca.c
index f97c8fb..5b6df37 100644
--- a/ext/ipp/sources/ippcp/src/pcpeccpverifydsaca.c
+++ b/ext/ipp/sources/ippcp/pcpeccpverifydsaca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Purpose:
@@ -35,18 +59,21 @@
// Purpose: Verify Signature (DSA version).
//
// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
+// ippStsNullPtrErr NULL == pEC
// NULL == pMsgDigest
// NULL == pSignX
// NULL == pSignY
// NULL == pResult
//
-// ippStsContextMatchErr illegal pECC->idCtx
+// ippStsContextMatchErr illegal pEC->idCtx
// illegal pMsgDigest->idCtx
// illegal pSignX->idCtx
// illegal pSignY->idCtx
//
// ippStsMessageErr MsgDigest >= order
+// MsgDigest < 0
+//
+// ippStsRangeErr SignX < 0 or SignY < 0
//
// ippStsNoErr no errors
//
@@ -54,7 +81,7 @@
// pMsgDigest pointer to the message representative to be signed
// pSignX,pSignY pointer to the signature
// pResult pointer to the result: ippECValid/ippECInvalidSignature
-// pECC pointer to the ECCP context
+// pEC pointer to the ECCP context
//
// Note:
// - signer's key must be set up in ECCP context
@@ -144,9 +171,6 @@ IPPFUN(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest,
pModEngine);
/* compute h1*BasePoint + h2*publicKey */
- //gfec_PointProduct(&P,
- // &G, h1, orderLen, &Public, h2, orderLen,
- // pEC, (Ipp8u*)ECP_SBUFFER(pEC));
gfec_BasePointProduct(&P,
h1, orderLen, &Public, h2, orderLen,
pEC, (Ipp8u*)ECP_SBUFFER(pEC));
diff --git a/ext/ipp/sources/ippcp/pcpeccpverifynrca.c b/ext/ipp/sources/ippcp/pcpeccpverifynrca.c
new file mode 100644
index 0000000..d011c21
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpverifynrca.c
@@ -0,0 +1,193 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (Verify Signature, NR version)
+//
+// Contents:
+// ippsECCPVerifyNR()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPVerifyNR
+//
+// Purpose: Verify Signature (NR version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pSignX
+// NULL == pSignY
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pMsgDigest->idCtx
+// illegal pSignX->idCtx
+// illegal pSignY->idCtx
+//
+// ippStsMessageErr 0> MsgDigest
+// order<= MsgDigest
+//
+// ippStsRangeErr SignX < 0 or SignY < 0
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pSignX,pSignY pointer to the signature
+// pResult pointer to the result: ippECValid/ippECInvalidSignature
+// pEC pointer to the ECCP context
+//
+// Note:
+// - signer's key must be set up in ECCP context
+// before ippsECCPVerifyNR() usage
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPVerifyNR,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pSignX, const IppsBigNumState* pSignY,
+ IppECResult* pResult,
+ IppsECCPState* pEC))
+{
+ gsModEngine* pModEngine;
+ BNU_CHUNK_T* pOrder;
+ int orderLen;
+
+ BNU_CHUNK_T* pMsgData;
+ int msgLen;
+
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ pModEngine = ECP_MONT_R(pEC);
+ pOrder = MOD_MODULUS(pModEngine);
+ orderLen = MOD_LEN(pModEngine);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ pMsgData = BN_NUMBER(pMsgDigest);
+ msgLen = BN_SIZE(pMsgDigest);
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, orderLen), ippStsMessageErr);
+
+ /* test result */
+ IPP_BAD_PTR1_RET(pResult);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignX,pSignY);
+ pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) );
+ pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignX), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignY), ippStsRangeErr);
+
+ {
+ IppECResult vResult = ippECInvalidSignature;
+
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+
+ int elmLen = GFP_FELEN(pGFE);
+ int pelmLen = GFP_PELEN(pGFE);
+
+ BNU_CHUNK_T* pH1 = cpGFpGetPool(3, pGFE);
+ BNU_CHUNK_T* pH2 = pH1 + pelmLen;
+ BNU_CHUNK_T* pR1 = pH2 + pelmLen;
+ BNU_CHUNK_T* pF = pR1 + pelmLen;
+
+ /* test signature value */
+ if(0<cpBN_tst(pSignX) && 0<cpBN_tst(pSignY) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignX),BN_SIZE(pSignX), pOrder,orderLen) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignY),BN_SIZE(pSignY), pOrder,orderLen)) {
+
+ /* validate signature */
+ IppsGFpECPoint P, G, Public;
+ cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
+ cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
+ cpEcGFpInitPoint(&Public, ECP_PUBLIC(pEC), ECP_FINITE_POINT, pEC);
+
+ /* expand signature: H1 = signY, H2 = signX */
+ cpGFpElementCopyPadd(pH1, orderLen, BN_NUMBER(pSignY), BN_SIZE(pSignY));
+ cpGFpElementCopyPadd(pH2, orderLen, BN_NUMBER(pSignX), BN_SIZE(pSignX));
+
+ /* compute H1*BasePoint + H2*publicKey */
+ gfec_BasePointProduct(&P,
+ pH1, orderLen, &Public, pH2, orderLen,
+ pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+
+ /* P.X */
+ if(gfec_GetPoint(pH1, NULL, &P, pEC)) {
+ /* H1 = int(P.X) mod order */
+ GFP_METHOD(pGFE)->decode(pH1, pH1, pGFE);
+ elmLen = cpMod_BNU(pH1, elmLen, pOrder, orderLen);
+ cpGFpElementPadd(pH1+elmLen, orderLen-elmLen, 0);
+
+ /* recovered message: (SignX - H1) mod order */
+ cpModSub_BNU(pH1, pH2, pH1, pOrder, orderLen, pF);
+
+ /* and compare with input message*/
+ cpGFpElementCopyPadd(pH2, orderLen, pMsgData, msgLen);
+ if(GFP_EQ(pH1, pH2, orderLen))
+ vResult = ippECValid;
+ }
+
+ cpEcGFpReleasePool(1, pEC);
+ cpGFpReleasePool(3, pGFE);
+ }
+
+ *pResult = vResult;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccpverifysm2ca.c b/ext/ipp/sources/ippcp/pcpeccpverifysm2ca.c
new file mode 100644
index 0000000..f630319
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccpverifysm2ca.c
@@ -0,0 +1,196 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// EC over Prime Finite Field (Verify Signature, SM2 version)
+//
+// Contents:
+// ippsECCPVerifySM2()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+
+/*F*
+// Name: ippsECCPVerifySM2
+//
+// Purpose: Verify Signature (SM2 version).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPublic
+// NULL == pSignR
+// NULL == pSignS
+// NULL == pResult
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// illegal pMsgDigest->idCtx
+// illegal pRegPublic->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsMessageErr 0> MsgDigest
+// order<= MsgDigest
+//
+// ippStsRangeErr SignR < 0 or SignS < 0
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to being signed
+// pRegPublic pointer to the regular public key
+// pSignR,pSignS pointer to the signature
+// pResult pointer to the result: ippECValid/ippECInvalidSignature
+// pEC pointer to the ECCP context
+//
+*F*/
+IPPFUN(IppStatus, ippsECCPVerifySM2,(const IppsBigNumState* pMsgDigest,
+ const IppsECCPPointState* pRegPublic,
+ const IppsBigNumState* pSignR, const IppsBigNumState* pSignS,
+ IppECResult* pResult,
+ IppsECCPState* pEC))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* use aligned EC context */
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test regular public key */
+ IPP_BAD_PTR1_RET(pRegPublic);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
+ IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ /* test result */
+ IPP_BAD_PTR1_RET(pResult);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignR, pSignS);
+ pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, ALIGN_VAL) );
+ pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignR), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignS), ippStsRangeErr);
+
+ {
+ IppECResult vResult = ippECInvalidSignature;
+
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int orderLen = MOD_LEN(pMontR);
+
+ BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
+ int msgLen = BN_SIZE(pMsgDigest);
+
+ /* test message value */
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, orderLen), ippStsMessageErr);
+
+ /* test signature value */
+ if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignR), BN_SIZE(pSignR), 0) &&
+ !cpEqu_BNU_CHUNK(BN_NUMBER(pSignS), BN_SIZE(pSignS), 0) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignR), BN_SIZE(pSignR), pOrder, orderLen) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignS), BN_SIZE(pSignS), pOrder, orderLen)) {
+
+ int elmLen = GFP_FELEN(pGFE);
+ int ns;
+
+ BNU_CHUNK_T* r = cpGFpGetPool(4, pGFE);
+ BNU_CHUNK_T* s = r+orderLen;
+ BNU_CHUNK_T* t = s+orderLen;
+ BNU_CHUNK_T* f = t+orderLen;
+
+ /* expand signatire's components */
+ cpGFpElementCopyPadd(r, orderLen, BN_NUMBER(pSignR), BN_SIZE(pSignR));
+ cpGFpElementCopyPadd(s, orderLen, BN_NUMBER(pSignS), BN_SIZE(pSignS));
+
+ /* t = (r+s) mod order */
+ cpModAdd_BNU(t, r, s, pOrder, orderLen, f);
+
+ /* P = [s]G +[t]regPublic, t = P.x */
+ {
+ IppsGFpECPoint P, G;
+ cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
+ cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
+
+ gfec_BasePointProduct(&P,
+ s, orderLen, pRegPublic, t, orderLen,
+ pEC, (Ipp8u*)ECP_SBUFFER(pEC));
+
+ gfec_GetPoint(t, NULL, &P, pEC);
+ GFP_METHOD(pGFE)->decode(t, t, pGFE);
+ ns = cpMod_BNU(t, elmLen, pOrder, orderLen);
+
+ cpEcGFpReleasePool(1, pEC);
+ }
+
+ /* t = (msg+t) mod order */
+ cpGFpElementCopyPadd(f, orderLen, pMsgData, msgLen);
+ cpModAdd_BNU(t, t, f, pOrder, orderLen, f);
+
+ if(GFP_EQ(t, r, orderLen))
+ vResult = ippECValid;
+
+ cpGFpReleasePool(4, pGFE);
+ }
+
+ *pResult = vResult;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpeccresultca.c b/ext/ipp/sources/ippcp/pcpeccresultca.c
new file mode 100644
index 0000000..6c4b191
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpeccresultca.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// ECC operation results
+//
+// Contents:
+// ippsECCGetResultString()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+
+/*F*
+// Name: ippsECCGetResultString
+//
+// Purpose: Returns the string corresponding to code
+// that represents the result of validation
+//
+// Parameters:
+// code The code of the validation result
+//
+*F*/
+
+IPPFUN( const char*, ippsECCGetResultString, (IppECResult code))
+{
+ switch(code) {
+ case ippECValid: return "Validation pass successfully";
+ case ippECCompositeBase: return "Finite Field produced by Composite";
+ case ippECComplicatedBase: return "Too much non-zero terms in the polynomial";
+ case ippECIsZeroDiscriminant: return "Zero discriminamt";
+ case ippECCompositeOrder: return "Composite Base Point order";
+ case ippECInvalidOrder: return "Invalid Base Point order";
+ case ippECIsWeakMOV: return "EC cover by MOV Reduction Test";
+ case ippECIsWeakSSSA: return "EC cover by SS-SA Reduction Test";
+ case ippECIsSupersingular: return "EC is supersingular curve";
+ case ippECInvalidPrivateKey: return "Invalid Private Key";
+ case ippECInvalidPublicKey: return "Invalid Public Key";
+ case ippECInvalidKeyPair: return "Invalid Key Pair";
+ case ippECPointOutOfGroup: return "Point is out of group";
+ case ippECPointIsAtInfinite: return "Point at Infinity";
+ case ippECPointIsNotValid: return "Invalid EC Point";
+ case ippECPointIsEqual: return "Points are equal";
+ case ippECPointIsNotEqual: return "Points are different";
+ case ippECInvalidSignature: return "Invalid Signature";
+ default: return "Unknown ECC result";
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpecprime.h b/ext/ipp/sources/ippcp/pcpecprime.h
new file mode 100644
index 0000000..3174a37
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpecprime.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Fixed EC primes
+//
+//
+*/
+
+#if !defined(_PCP_ECPRIME_H)
+#define _PCP_ECPRIME_H
+
+#include "owndefs.h"
+#include "pcpbnuimpl.h"
+
+
+/*
+// Recommended (NIST's) underlying EC Primes
+*/
+extern const BNU_CHUNK_T secp112r1_p[]; // (2^128 -3)/76439
+extern const BNU_CHUNK_T secp112r2_p[]; // (2^128 -3)/76439
+extern const BNU_CHUNK_T secp128r1_p[]; // 2^128 -2^97 -1
+extern const BNU_CHUNK_T secp128r2_p[]; // 2^128 -2^97 -1
+extern const BNU_CHUNK_T secp160r1_p[]; // 2^160 -2^31 -1
+extern const BNU_CHUNK_T secp160r2_p[]; // 2^160 -2^32 -2^14 -2^12 -2^9 -2^8 -2^7 -2^2 -1
+extern const BNU_CHUNK_T secp192r1_p[]; // 2^192 -2^64 -1
+extern const BNU_CHUNK_T secp224r1_p[]; // 2^224 -2^96 +1
+extern const BNU_CHUNK_T secp256r1_p[]; // 2^256 -2^224 +2^192 +2^96 -1
+extern const BNU_CHUNK_T secp384r1_p[]; // 2^384 -2^128 -2^96 +2^32 -1
+extern const BNU_CHUNK_T secp521r1_p[]; // 2^521 -1
+
+extern const BNU_CHUNK_T tpmBN_p256p_p[]; // TPM BN_P256
+
+/*
+// Recommended (SM2) underlying EC Prime
+*/
+extern const BNU_CHUNK_T tpmSM2_p256_p[]; // TPM SM2_P256
+
+#endif /* _PCP_ECPRIME_H */
diff --git a/ext/ipp/sources/ippcp/pcpgfp.c b/ext/ipp/sources/ippcp/pcpgfp.c
new file mode 100644
index 0000000..7e9ba57
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp.c
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// cpGFpGetSize()
+// cpGFpInitGFp()
+//
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*
+// size of GFp engine context (Montgomery)
+*/
+int cpGFpGetSize(int feBitSize, int peBitSize, int numpe)
+{
+ int ctxSize = 0;
+ int elemLen = BITS_BNU_CHUNK(feBitSize);
+ int pelmLen = BITS_BNU_CHUNK(peBitSize);
+
+ /* size of GFp engine */
+ ctxSize = sizeof(gsModEngine)
+ + elemLen*sizeof(BNU_CHUNK_T) /* modulus */
+ + elemLen*sizeof(BNU_CHUNK_T) /* mont_R */
+ + elemLen*sizeof(BNU_CHUNK_T) /* mont_R^2 */
+ + elemLen*sizeof(BNU_CHUNK_T) /* half of modulus */
+ + elemLen*sizeof(BNU_CHUNK_T) /* quadratic non-residue */
+ + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* pool */
+
+ ctxSize += sizeof(IppsGFpState); /* size of IppsGFPState */
+ return ctxSize;
+}
+
+/*
+// init GFp engine context (Montgomery)
+*/
+static void cpGFEInit(gsModEngine* pGFE, int modulusBitSize, int peBitSize, int numpe)
+{
+ int modLen = BITS_BNU_CHUNK(modulusBitSize);
+ int pelmLen = BITS_BNU_CHUNK(peBitSize);
+
+ Ipp8u* ptr = (Ipp8u*)pGFE;
+
+ /* clear whole context */
+ PaddBlock(0, ptr, sizeof(gsModEngine));
+ ptr += sizeof(gsModEngine);
+
+ GFP_PARENT(pGFE) = NULL;
+ GFP_EXTDEGREE(pGFE) = 1;
+ GFP_FEBITLEN(pGFE) = modulusBitSize;
+ GFP_FELEN(pGFE) = modLen;
+ GFP_FELEN32(pGFE) = BITS2WORD32_SIZE(modulusBitSize);
+ GFP_PELEN(pGFE) = pelmLen;
+ //GFP_METHOD(pGFE) = method;
+ GFP_MODULUS(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
+ GFP_MNT_R(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
+ GFP_MNT_RR(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
+ GFP_HMODULUS(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
+ GFP_QNR(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
+ GFP_POOL(pGFE) = (BNU_CHUNK_T*)(ptr);/* ptr += modLen*sizeof(BNU_CHUNK_T);*/
+ GFP_MAXPOOL(pGFE) = numpe;
+ GFP_USEDPOOL(pGFE) = 0;
+
+ cpGFpElementPadd(GFP_MODULUS(pGFE), modLen, 0);
+ cpGFpElementPadd(GFP_MNT_R(pGFE), modLen, 0);
+ cpGFpElementPadd(GFP_MNT_RR(pGFE), modLen, 0);
+ cpGFpElementPadd(GFP_HMODULUS(pGFE), modLen, 0);
+ cpGFpElementPadd(GFP_QNR(pGFE), modLen, 0);
+}
+
+IppStatus cpGFpInitGFp(int primeBitSize, IppsGFpState* pGF)
+{
+ IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
+ IPP_BAD_PTR1_RET(pGF);
+ pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
+
+ {
+ Ipp8u* ptr = (Ipp8u*)pGF;
+
+ GFP_ID(pGF) = idCtxGFP;
+ GFP_PMA(pGF) = (gsModEngine*)(ptr+sizeof(IppsGFpState));
+ cpGFEInit(GFP_PMA(pGF), primeBitSize, primeBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_exp.c b/ext/ipp/sources/ippcp/pcpgfp_exp.c
new file mode 100644
index 0000000..ee26e0d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_exp.c
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpExp
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+
+BNU_CHUNK_T* cpGFpExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, gsModEngine* pGFE)
+{
+ int elemLen = GFP_FELEN(pGFE);
+ cpMontExpBin_BNU(pR, pA,cpFix_BNU(pA, elemLen), pE,cpFix_BNU(pE, nsE), pGFE);
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_get.c b/ext/ipp/sources/ippcp/pcpgfp_get.c
new file mode 100644
index 0000000..f05346c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_get.c
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpGet
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpGet(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pElm, gsModEngine* pGFE)
+{
+ int elemLen = GFP_FELEN(pGFE);
+
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(pTmp !=NULL);
+
+ GFP_METHOD(pGFE)->decode(pTmp, pElm, pGFE);
+ ZEXPAND_COPY_BNU(pDataA, nsA, pTmp, elemLen);
+
+ cpGFpReleasePool(1, pGFE);
+ return pDataA;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_getoctstring.c b/ext/ipp/sources/ippcp/pcpgfp_getoctstring.c
new file mode 100644
index 0000000..36ec4cc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_getoctstring.c
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpSetOctString
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+Ipp8u* cpGFpGetOctString(Ipp8u* pStr, int strSize, const BNU_CHUNK_T* pElm, gsModEngine* pGFE)
+{
+ int elemLen = GFP_FELEN(pGFE);
+ int error;
+
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(pTmp !=NULL);
+
+ GFP_METHOD(pGFE)->decode(pTmp, pElm, pGFE);
+ error = (0 == cpToOctStr_BNU(pStr, strSize, pTmp, elemLen));
+
+ cpGFpReleasePool(1, pGFE);
+ return error ? NULL : pStr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_gfeqnr.c b/ext/ipp/sources/ippcp/pcpgfp_gfeqnr.c
new file mode 100644
index 0000000..603c492
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_gfeqnr.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// cpGFEqnr()
+//
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+void cpGFEqnr(gsModEngine* pGFE)
+{
+ BNU_CHUNK_T* pQnr = GFP_QNR(pGFE);
+
+ int elemLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* e = cpGFpGetPool(3, pGFE);
+ BNU_CHUNK_T* t = e+elemLen;
+ BNU_CHUNK_T* p1 = t+elemLen;
+ //tbcd: temporary excluded: assert(NULL!=e);
+
+ cpGFpElementCopyPadd(p1, elemLen, GFP_MNT_R(pGFE), elemLen);
+
+ /* (modulus-1)/2 */
+ cpLSR_BNU(e, GFP_MODULUS(pGFE), elemLen, 1);
+
+ /* find a non-square g, where g^{(modulus-1)/2} = -1 */
+ cpGFpElementCopy(pQnr, p1, elemLen);
+ do {
+ cpGFpAdd(pQnr, pQnr, p1, pGFE);
+ cpGFpExp(t, pQnr, e, elemLen, pGFE);
+ cpGFpNeg(t, t, pGFE);
+ } while( !GFP_EQ(p1, t, elemLen) );
+
+ cpGFpReleasePool(3, pGFE);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_inv.c b/ext/ipp/sources/ippcp/pcpgfp_inv.c
new file mode 100644
index 0000000..af3fd99
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_inv.c
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpInv
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+BNU_CHUNK_T* cpGFpInv(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
+{
+ GFP_METHOD(pGFE)->decode(pR, pA, pGFE);
+ gs_mont_inv(pR, pR, pGFE, alm_mont_inv);
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_rand.c b/ext/ipp/sources/ippcp/pcpgfp_rand.c
new file mode 100644
index 0000000..e97021d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_rand.c
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpRand
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpRand(BNU_CHUNK_T* pR, gsModEngine* pGFE, IppBitSupplier rndFunc, void* pRndParam)
+{
+ int elemLen = GFP_FELEN(pGFE);
+ int reqBitSize = GFP_FEBITLEN(pGFE)+GFP_RAND_ADD_BITS;
+ int nsR = (reqBitSize +BITSIZE(BNU_CHUNK_T)-1)/BITSIZE(BNU_CHUNK_T);
+
+ int internal_err;
+
+ BNU_CHUNK_T* pPool = cpGFpGetPool(2, pGFE);
+ //tbcd: temporary excluded: assert(pPool!=NULL);
+
+ cpGFpElementPadd(pPool, nsR, 0);
+
+ internal_err = ippStsNoErr != rndFunc((Ipp32u*)pPool, reqBitSize, pRndParam);
+
+ if(!internal_err) {
+ nsR = cpMod_BNU(pPool, nsR, GFP_MODULUS(pGFE), elemLen);
+ cpGFpElementPadd(pPool+nsR, elemLen-nsR, 0);
+ GFP_METHOD(pGFE)->encode(pR, pPool, pGFE);
+ }
+
+ cpGFpReleasePool(2, pGFE);
+ return internal_err? NULL : pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_set.c b/ext/ipp/sources/ippcp/pcpgfp_set.c
new file mode 100644
index 0000000..0b7ecbe
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_set.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpSet
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpSet(BNU_CHUNK_T* pElm, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFE)
+{
+ const BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
+ int elemLen = GFP_FELEN(pGFE);
+
+ if(0 <= cpCmp_BNU(pDataA, nsA, pModulus, elemLen))
+ return NULL;
+ else {
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(pTmp !=NULL);
+
+ ZEXPAND_COPY_BNU(pTmp, elemLen, pDataA, nsA);
+ GFP_METHOD(pGFE)->encode(pElm, pTmp, pGFE);
+
+ cpGFpReleasePool(1, pGFE);
+ return pElm;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_setgfp.c b/ext/ipp/sources/ippcp/pcpgfp_setgfp.c
new file mode 100644
index 0000000..d607c58
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_setgfp.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// cpGFpSetGFp()
+//
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+static void cpGFESet(gsModEngine* pGFE, const BNU_CHUNK_T* pPrime, int primeBitSize, const gsModMethod* method)
+{
+ int primeLen = BITS_BNU_CHUNK(primeBitSize);
+
+ /* arithmetic methods */
+ GFP_METHOD(pGFE) = method;
+
+ /* store modulus */
+ COPY_BNU(GFP_MODULUS(pGFE), pPrime, primeLen);
+
+ /* montgomery factor */
+ GFP_MNT_FACTOR(pGFE) = gsMontFactor(GFP_MODULUS(pGFE)[0]);
+
+ /* montgomery identity (R) */
+ ZEXPAND_BNU(GFP_MNT_R(pGFE), 0, primeLen);
+ GFP_MNT_R(pGFE)[primeLen] = 1;
+ cpMod_BNU(GFP_MNT_R(pGFE), primeLen+1, GFP_MODULUS(pGFE), primeLen);
+
+ /* montgomery domain converter (RR) */
+ ZEXPAND_BNU(GFP_MNT_RR(pGFE), 0, primeLen);
+ COPY_BNU(GFP_MNT_RR(pGFE)+primeLen, GFP_MNT_R(pGFE), primeLen);
+ cpMod_BNU(GFP_MNT_RR(pGFE), 2*primeLen, GFP_MODULUS(pGFE), primeLen);
+
+ /* half of modulus */
+ cpLSR_BNU(GFP_HMODULUS(pGFE), GFP_MODULUS(pGFE), primeLen, 1);
+
+ /* set qnr value */
+ cpGFEqnr(pGFE);
+}
+
+IppStatus cpGFpSetGFp(const BNU_CHUNK_T* pPrime, int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF)
+{
+ cpGFESet(GFP_PMA(pGF), pPrime, primeBitSize, method->arith);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_setoctstring.c b/ext/ipp/sources/ippcp/pcpgfp_setoctstring.c
new file mode 100644
index 0000000..661e9c7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_setoctstring.c
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpSetOctString
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpSetOctString(BNU_CHUNK_T* pElm, const Ipp8u* pStr, int strSize, gsModEngine* pGFE)
+{
+ int elemLen = GFP_FELEN(pGFE);
+
+ if((int)(elemLen*sizeof(BNU_CHUNK_T)) < strSize)
+ return NULL;
+
+ {
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(pTmp !=NULL);
+ {
+ int nsTmp = cpFromOctStr_BNU(pTmp, pStr, strSize);
+ BNU_CHUNK_T* ret = cpGFpSet(pElm, pTmp, nsTmp, pGFE);
+
+ cpGFpReleasePool(1, pGFE);
+ return ret==NULL? NULL : pElm;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfp_sqrt.c b/ext/ipp/sources/ippcp/pcpgfp_sqrt.c
new file mode 100644
index 0000000..82f5a84
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfp_sqrt.c
@@ -0,0 +1,173 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over prime GF(p).
+//
+// Context:
+// cpGFpSqrt
+//
+*/
+#include "owncp.h"
+
+#include "pcpbn.h"
+#include "pcpgfpstuff.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+static int factor2(BNU_CHUNK_T* pA, int nsA)
+{
+ int factor = 0;
+ int bits;
+
+ int i;
+ for(i=0; i<nsA; i++) {
+ int ntz = cpNTZ_BNU(pA[i]);
+ factor += ntz;
+ if(ntz<BITSIZE(BNU_CHUNK_T))
+ break;
+ }
+
+ bits = factor;
+ if(bits >= BITSIZE(BNU_CHUNK_T)) {
+ int nchunk = bits/BITSIZE(BNU_CHUNK_T);
+ cpGFpElementCopyPadd(pA, nsA, pA+nchunk, nsA-nchunk);
+ bits %= BITSIZE(BNU_CHUNK_T);
+ }
+ if(bits)
+ cpLSR_BNU(pA, pA, nsA, bits);
+
+ return factor;
+}
+
+static BNU_CHUNK_T* cpGFpExp2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, int e, gsModEngine* pGFE)
+{
+ cpGFpElementCopy(pR, pA, GFP_FELEN(pGFE));
+ while(e--) {
+ GFP_METHOD(pGFE)->sqr(pR, pR, pGFE);
+ }
+ return pR;
+}
+
+
+/* returns:
+ 0, if a - qnr
+ 1, if sqrt is found
+*/
+int cpGFpSqrt(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
+{
+ int elemLen = GFP_FELEN(pGFE);
+ int poolelementLen = GFP_PELEN(pGFE);
+ int resultFlag = 1;
+
+ /* case A==0 */
+ if( GFP_IS_ZERO(pA, elemLen) )
+ cpGFpElementPadd(pR, elemLen, 0);
+
+ /* general case */
+ else {
+ BNU_CHUNK_T* q = cpGFpGetPool(4, pGFE);
+ BNU_CHUNK_T* x = q + poolelementLen;
+ BNU_CHUNK_T* y = x + poolelementLen;
+ BNU_CHUNK_T* z = y + poolelementLen;
+
+ int s;
+
+ //tbcd: temporary excluded: assert(q!=NULL);
+
+ /* z=1 */
+ GFP_ONE(z, elemLen);
+
+ /* (modulus-1) = 2^s*q */
+ cpSub_BNU(q, GFP_MODULUS(pGFE), z, elemLen);
+ s = factor2(q, elemLen);
+
+ /*
+ // initialization
+ */
+
+ /* y = qnr^q */
+ cpGFpExp(y, GFP_QNR(pGFE), q,elemLen, pGFE);
+ /* x = a^((q-1)/2) */
+ cpSub_BNU(q, q, z, elemLen);
+ cpLSR_BNU(q, q, elemLen, 1);
+ cpGFpExp(x, pA, q, elemLen, pGFE);
+ /* z = a*x^2 */
+ GFP_METHOD(pGFE)->mul(z, x, x, pGFE);
+ GFP_METHOD(pGFE)->mul(z, pA, z, pGFE);
+ /* R = a*x */
+ GFP_METHOD(pGFE)->mul(pR, pA, x, pGFE);
+
+ while( !GFP_EQ(z, MOD_MNT_R(pGFE), elemLen) ) {
+ int m = 0;
+ cpGFpElementCopy(q, z, elemLen);
+
+ for(m=1; m<s; m++) {
+ GFP_METHOD(pGFE)->mul(q, q, q, pGFE);
+ if( GFP_EQ(q, MOD_MNT_R(pGFE), elemLen) )
+ break;
+ }
+
+ if(m==s) {
+ /* A is quadratic non-residue */
+ resultFlag = 0;
+ break;
+ }
+ else {
+ /* exponent reduction */
+ cpGFpExp2(q, y, (s-m-1), pGFE); /* q = y^(2^(s-m-1)) */
+ GFP_METHOD(pGFE)->mul(y, q, q, pGFE); /* y = q^2 */
+ GFP_METHOD(pGFE)->mul(pR, q, pR, pGFE); /* R = q*R */
+ GFP_METHOD(pGFE)->mul(z, y, z, pGFE); /* z = z*y */
+ s = m;
+ }
+ }
+
+ /* choose smallest between R and (modulus-R) */
+ GFP_METHOD(pGFE)->decode(q, pR, pGFE);
+ if(GFP_GT(q, GFP_HMODULUS(pGFE), elemLen))
+ GFP_METHOD(pGFE)->neg(pR, pR, pGFE);
+
+ cpGFpReleasePool(4, pGFE);
+ }
+
+ return resultFlag;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpadd.c b/ext/ipp/sources/ippcp/pcpgfpadd.c
new file mode 100644
index 0000000..cf08a71
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpadd.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpAdd()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpAdd
+//
+// Purpose: Sum of GF elements
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpAdd,(const IppsGFpElement* pA, const IppsGFpElement* pB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ GFP_METHOD(pGFE)->add(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pB), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpaddpe.c b/ext/ipp/sources/ippcp/pcpgfpaddpe.c
new file mode 100644
index 0000000..17e0b00
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpaddpe.c
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpAdd_PE()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpAdd_PE
+//
+// Purpose: Sum of GF element and parent GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pParentB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pParentB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr pGFp does not specify prime field
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pParentB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpAdd_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pParentB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pParentB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( (GFPE_ROOM(pParentB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
+
+ cpGFpxAdd_GFE(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pParentB), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpbufsize.c b/ext/ipp/sources/ippcp/pcpgfpbufsize.c
new file mode 100644
index 0000000..2cdb5e6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpbufsize.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpScratchBufferSize
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpScratchBufferSize
+//
+// Purpose: Gets the size of the scratch buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pGFp == NULL
+// pBufferSize == NULL
+// ippStsContextMatchErr incorrect pGFp's context id
+// ippStsBadArgErr 0>=nExponents
+// nExponents>6
+// ippStsNoErr no error
+//
+// Parameters:
+// nExponents Number of exponents.
+// ExpBitSize Maximum bit size of the exponents.
+// pGFp Pointer to the context of the finite field.
+// pBufferSize Pointer to the calculated buffer size in bytes.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGFp, int* pBufferSize))
+{
+ IPP_BAD_PTR2_RET(pGFp, pBufferSize);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( 0>=nExponents ||nExponents>IPP_MAX_EXPONENT_NUM, ippStsBadArgErr);
+ IPP_BADARG_RET( 0>=ExpBitSize, ippStsBadArgErr);
+
+ {
+ int elmDataSize = GFP_FELEN(GFP_PMA(pGFp))*sizeof(BNU_CHUNK_T);
+
+ /* get window_size */
+ int w = (nExponents==1)? cpGFpGetOptimalWinSize(ExpBitSize) : /* use optimal window size, if single-scalar operation */
+ nExponents; /* or pseudo-oprimal if multi-scalar operation */
+
+ /* number of table entries */
+ int nPrecomputed = 1<<w;
+
+ *pBufferSize = elmDataSize*nPrecomputed + (CACHE_LINE_SIZE-1);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpcmpelem.c b/ext/ipp/sources/ippcp/pcpgfpcmpelem.c
new file mode 100644
index 0000000..e9f99c6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpcmpelem.c
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpCmpElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpCmpElement
+//
+// Purpose: Compares GF Elements
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pB
+// NULL == pResult
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pB Pointer to the context of the second finite field element.
+// pResult Pointer to the result of the comparison.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpCmpElement,(const IppsGFpElement* pA, const IppsGFpElement* pB,
+ int* pResult,
+ const IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pResult, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pB)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ {
+ int flag = cpGFpElementCmp(GFPE_DATA(pA), GFPE_DATA(pB), GFP_FELEN(pGFE));
+ if( GFP_IS_BASIC(pGFE) )
+ *pResult = (0==flag)? IPP_IS_EQ : (0<flag)? IPP_IS_GT : IPP_IS_LT;
+ else
+ *pResult = (0==flag)? IPP_IS_EQ : IPP_IS_NE;
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpconj.c b/ext/ipp/sources/ippcp/pcpgfpconj.c
new file mode 100644
index 0000000..aa89429
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpconj.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpConj()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpConj
+//
+// Purpose: Conjugate GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr 2!=GFP_EXTDEGREE(pGFE)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the source finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpConj,(const IppsGFpElement* pA,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( 2!=GFP_EXTDEGREE(pGFE), ippStsBadArgErr )
+
+ cpGFpxConj(GFPE_DATA(pR), GFPE_DATA(pA), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpcpyelem.c b/ext/ipp/sources/ippcp/pcpgfpcpyelem.c
new file mode 100644
index 0000000..3981c98
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpcpyelem.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpCpyElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+
+/*F*
+// Name: ippsGFpCpyElement
+//
+// Purpose: Copy GF Element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA pointer to the source element
+// pR pointer to the result element
+// pGFp pointer to Finite Field context
+*F*/
+
+IPPFUN(IppStatus, ippsGFpCpyElement, (const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ cpGFpElementCopy(GFPE_DATA(pR), GFPE_DATA(pA), GFP_FELEN(pGFE));
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec.c b/ext/ipp/sources/ippcp/pcpgfpec.c
new file mode 100644
index 0000000..a0307dd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// cpGFpECGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+int cpGFpECGetSize(int basicDeg, int basicElmBitSize)
+{
+ int ctxSize = 0;
+ int elemLen = basicDeg*BITS_BNU_CHUNK(basicElmBitSize);
+
+ int maxOrderBits = 1+ basicDeg*basicElmBitSize;
+ #if defined(_LEGACY_ECCP_SUPPORT_)
+ int maxOrderLen = BITS_BNU_CHUNK(maxOrderBits);
+ #endif
+
+ int modEngineCtxSize;
+ if(ippStsNoErr==gsModEngineGetSize(maxOrderBits, MONT_DEFAULT_POOL_LENGTH, &modEngineCtxSize)) {
+
+ ctxSize = sizeof(IppsGFpECState)
+ +elemLen*sizeof(BNU_CHUNK_T) /* EC coeff A */
+ +elemLen*sizeof(BNU_CHUNK_T) /* EC coeff B */
+ +elemLen*sizeof(BNU_CHUNK_T) /* generator G.x */
+ +elemLen*sizeof(BNU_CHUNK_T) /* generator G.y */
+ +elemLen*sizeof(BNU_CHUNK_T) /* generator G.z */
+ +modEngineCtxSize /* mont engine (R) */
+ +elemLen*sizeof(BNU_CHUNK_T) /* cofactor */
+ #if defined(_LEGACY_ECCP_SUPPORT_)
+ +2*elemLen*3*sizeof(BNU_CHUNK_T) /* regular and ephemeral public keys */
+ +2*maxOrderLen*sizeof(BNU_CHUNK_T) /* regular and ephemeral private keys */
+ #endif
+ +elemLen*sizeof(BNU_CHUNK_T)*3*EC_POOL_SIZE;
+ }
+ return ctxSize;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_add.c b/ext/ipp/sources/ippcp/pcpgfpec_add.c
new file mode 100644
index 0000000..727d91b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_add.c
@@ -0,0 +1,161 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_point_add()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+/*
+// S1 = y1*z2^3
+// S2 = y2*z1^3
+//
+// U1 = x1*z2^2
+// U2 = x2*z1^2
+
+// R = S2-S1
+// H = U2-U1
+//
+// x3 = -H^3 -2*U1*H^2 +R2
+// y3 = -S1*H^3 +R*(U1*H^2 -x3)
+// z3 = z1*z2*H
+//
+// complexity = 4s+12m
+*/
+
+void gfec_point_add(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, const BNU_CHUNK_T* pQdata, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
+ mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
+ mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
+ mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
+
+ /* coordinates of P */
+ const BNU_CHUNK_T* px1 = pPdata;
+ const BNU_CHUNK_T* py1 = pPdata+elemLen;
+ const BNU_CHUNK_T* pz1 = pPdata+2*elemLen;
+
+ /* coordinates of Q */
+ const BNU_CHUNK_T* px2 = pQdata;
+ const BNU_CHUNK_T* py2 = pQdata+elemLen;
+ const BNU_CHUNK_T* pz2 = pQdata+2*elemLen;
+
+ BNU_CHUNK_T inftyP = GFPE_IS_ZERO_CT(pz1, elemLen);
+ BNU_CHUNK_T inftyQ = GFPE_IS_ZERO_CT(pz2, elemLen);
+
+ /* get temporary from top of EC point pool */
+ BNU_CHUNK_T* U1 = pEC->pPool;
+ BNU_CHUNK_T* U2 = U1 + elemLen;
+ BNU_CHUNK_T* S1 = U2 + elemLen;
+ BNU_CHUNK_T* S2 = S1 + elemLen;
+ BNU_CHUNK_T* H = S2 + elemLen;
+ BNU_CHUNK_T* R = H + elemLen;
+
+ BNU_CHUNK_T* pRx = R + elemLen; /* temporary result */
+ BNU_CHUNK_T* pRy = pRx+ elemLen;
+ BNU_CHUNK_T* pRz = pRy+ elemLen;
+
+ mul(S1, py1, pz2, pGFE); // S1 = Y1*Z2
+ sqr(U1, pz2, pGFE); // U1 = Z2^2
+
+ mul(S2, py2, pz1, pGFE); // S2 = Y2*Z1
+ sqr(U2, pz1, pGFE); // U2 = Z1^2
+
+ mul(S1, S1, U1, pGFE); // S1 = Y1*Z2^3
+ mul(S2, S2, U2, pGFE); // S2 = Y2*Z1^3
+
+ mul(U1, px1, U1, pGFE); // U1 = X1*Z2^2
+ mul(U2, px2, U2, pGFE); // U2 = X2*Z1^2
+
+ sub(R, S2, S1, pGFE); // R = S2-S1
+ sub(H, U2, U1, pGFE); // H = U2-U1
+
+ {
+ BNU_CHUNK_T mask_zeroH = GFPE_IS_ZERO_CT(H, elemLen);
+ BNU_CHUNK_T mask = mask_zeroH & ~inftyP & ~inftyQ;
+ if(mask) {
+ if( GFPE_IS_ZERO_CT(R, elemLen) )
+ gfec_point_double(pRdata, pPdata, pEC);
+ else
+ cpGFpElementPadd(pRdata, 3*elemLen, 0);
+ return;
+ }
+ }
+
+ mul(pRz, pz1, pz2, pGFE); // Z3 = Z1*Z2
+ sqr(U2, H, pGFE); // U2 = H^2
+ mul(pRz, pRz, H, pGFE); // Z3 = (Z1*Z2)*H
+ sqr(S2, R, pGFE); // S2 = R^2
+ mul(H, H, U2, pGFE); // H = H^3
+
+ mul(U1, U1, U2, pGFE); // U1 = U1*H^2
+ sub(pRx, S2, H, pGFE); // X3 = R^2 - H^3
+ mul2(U2, U1, pGFE); // U2 = 2*U1*H^2
+ mul(S1, S1, H, pGFE); // S1 = S1*H^3
+ sub(pRx, pRx, U2, pGFE); // X3 = (R^2 - H^3) -2*U1*H^2
+
+ sub(pRy, U1, pRx, pGFE); // Y3 = R*(U1*H^2 - X3) -S1*H^3
+ mul(pRy, pRy, R, pGFE);
+ sub(pRy, pRy, S1, pGFE);
+
+ cpMaskedReplace_ct(pRx, px2, elemLen*3, inftyP);
+ cpMaskedReplace_ct(pRx, px1, elemLen*3, inftyQ);
+
+ cpGFpElementCopy(pRdata, pRx, 3*elemLen);
+}
+#endif
+
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_addaffine.c b/ext/ipp/sources/ippcp/pcpgfpec_addaffine.c
new file mode 100644
index 0000000..9cf5293
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_addaffine.c
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_affine_point_add()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+/*
+// complexity = 3s+8m
+*/
+void gfec_affine_point_add(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, const BNU_CHUNK_T* pAdata, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
+ mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
+ mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
+ mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
+
+ BNU_CHUNK_T* mont1 = GFP_MNT_R(pGFE);
+
+ /* coordinates of projective P point */
+ const BNU_CHUNK_T* px = pPdata; /* x1 */
+ const BNU_CHUNK_T* py = pPdata+elemLen; /* y1 */
+ const BNU_CHUNK_T* pz = pPdata+2*elemLen; /* z1 */
+
+ /* coordinates of affine A point, az==mont(1) */
+ const BNU_CHUNK_T* ax = pAdata; /* x2 */
+ const BNU_CHUNK_T* ay = pAdata+elemLen; /* y2 */
+
+ BNU_CHUNK_T inftyP = GFPE_IS_ZERO_CT(px, elemLen) & GFPE_IS_ZERO_CT(py, elemLen);
+ BNU_CHUNK_T inftyA = GFPE_IS_ZERO_CT(ax, elemLen) & GFPE_IS_ZERO_CT(ay, elemLen);
+
+ /* get temporary from top of EC point pool */
+ BNU_CHUNK_T* U2 = pEC->pPool;
+ BNU_CHUNK_T* S2 = U2 + elemLen;
+ BNU_CHUNK_T* H = S2 + elemLen;
+ BNU_CHUNK_T* R = H + elemLen;
+
+ BNU_CHUNK_T* pRx = R + elemLen; /* temporary result */
+ BNU_CHUNK_T* pRy = pRx+ elemLen;
+ BNU_CHUNK_T* pRz = pRy+ elemLen;
+
+ sqr(R, pz, pGFE); // R = Z1^2
+ mul(S2, ay, pz, pGFE); // S2 = Y2*Z1
+ mul(U2, ax, R, pGFE); // U2 = X2*Z1^2
+ mul(S2, S2, R, pGFE); // S2 = Y2*Z1^3
+
+ sub(H, U2, px, pGFE); // H = U2-X1
+ sub(R, S2, py, pGFE); // R = S2-Y1
+
+ mul(pRz, H, pz, pGFE); // Z3 = H*Z1
+
+ sqr(U2, H, pGFE); // U2 = H^2
+ sqr(S2, R, pGFE); // S2 = R^2
+ mul(H, H, U2, pGFE); // H = H^3
+
+ mul(U2, U2, px, pGFE); // U2 = X1*H^2
+
+ mul(pRy, H, py, pGFE); // T = Y1*H^3
+
+ mul2(pRx, U2, pGFE); // X3 = 2*X1*H^2
+ sub(pRx, S2, pRx, pGFE); // X3 = R^2 - 2*X1*H^2
+ sub(pRx, pRx, H, pGFE); // X3 = R^2 - 2*X1*H^2 -H^3
+
+ sub(U2, U2, pRx, pGFE); // U2 = X1*H^2 - X3
+ mul(U2, U2, R, pGFE); // U2 = R*(X1*H^2 - X3)
+ sub(pRy, U2, pRy, pGFE); // Y3 = -Y1*H^3 + R*(X1*H^2 - X3)
+
+ cpMaskedReplace_ct(pRx, ax, elemLen, inftyP);
+ cpMaskedReplace_ct(pRy, ay, elemLen, inftyP);
+ cpMaskedReplace_ct(pRz, mont1, elemLen, inftyP);
+ cpMaskedReplace_ct(pRz, ax, elemLen, inftyP&inftyA);
+
+ cpMaskedReplace_ct(pRx, px, elemLen*3, inftyA);
+
+ cpGFpElementCopy(pRdata, pRx, 3*elemLen);
+}
+#endif
+
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_baseprod.c b/ext/ipp/sources/ippcp/pcpgfpec_baseprod.c
new file mode 100644
index 0000000..4c092d1
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_baseprod.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_BasePointProduct()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+IppsGFpECPoint* gfec_BasePointProduct(IppsGFpECPoint* pR,
+ const BNU_CHUNK_T* pScalarG, int scalarGlen,
+ const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalarP, int scalarPlen,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
+{
+ FIX_BNU(pScalarG, scalarGlen);
+ FIX_BNU(pScalarP, scalarPlen);
+
+ {
+ gsModEngine* pGForder = ECP_MONT_R(pEC);
+ int orderBits = MOD_BITSIZE(pGForder);
+ int orderLen = MOD_LEN(pGForder);
+ BNU_CHUNK_T* tmpScalarG = cpGFpGetPool(2, pGForder);
+ BNU_CHUNK_T* tmpScalarP = tmpScalarG+orderLen+1;
+
+ cpGFpElementCopyPadd(tmpScalarG, orderLen+1, pScalarG,scalarGlen);
+ cpGFpElementCopyPadd(tmpScalarP, orderLen+1, pScalarP,scalarPlen);
+
+ if(ECP_PREMULBP(pEC)) {
+ BNU_CHUNK_T* productG = cpEcGFpGetPool(2, pEC);
+ BNU_CHUNK_T* productP = productG+ECP_POINTLEN(pEC);
+
+ gfec_base_point_mul(productG, (Ipp8u*)tmpScalarG, orderBits, pEC);
+ gfec_point_mul(productP, ECP_POINT_X(pP), (Ipp8u*)tmpScalarP, orderBits, pEC, pScratchBuffer);
+ gfec_point_add(ECP_POINT_X(pR), productG, productP, pEC);
+
+ cpEcGFpReleasePool(2, pEC);
+ }
+
+ else {
+ gfec_point_prod(ECP_POINT_X(pR),
+ ECP_G(pEC), (Ipp8u*)tmpScalarG,
+ ECP_POINT_X(pP), (Ipp8u*)tmpScalarP,
+ orderBits,
+ pEC, pScratchBuffer);
+ }
+
+ cpGFpReleasePool(2, pGForder);
+ }
+
+ ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_comppont.c b/ext/ipp/sources/ippcp/pcpgfpec_comppont.c
new file mode 100644
index 0000000..bfb5adb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_comppont.c
@@ -0,0 +1,126 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_ComparePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+int gfec_ComparePoint(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ /* P or/and Q at Infinity */
+ if( !IS_ECP_FINITE_POINT(pP) )
+ return !IS_ECP_FINITE_POINT(pQ)? 1:0;
+ if( !IS_ECP_FINITE_POINT(pQ) )
+ return !IS_ECP_FINITE_POINT(pP)? 1:0;
+
+ /* Px==Qx && Py==Qy && Pz==Qz */
+ if( GFP_EQ(ECP_POINT_Z(pP), ECP_POINT_Z(pQ), elemLen)
+ &&GFP_EQ(ECP_POINT_X(pP), ECP_POINT_X(pQ), elemLen)
+ &&GFP_EQ(ECP_POINT_Y(pP), ECP_POINT_Y(pQ), elemLen))
+ return 1;
+
+ else {
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
+
+ int isEqu = 1;
+
+ BNU_CHUNK_T* pPtmp = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pQtmp = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pPz = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pQz = cpGFpGetPool(1, pGFE);
+
+ if(isEqu) {
+ /* Px*Qz^2 ~ Qx*Pz^2 */
+ if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Px * Qz^2 */
+ cpGFpElementCopy(pPtmp, ECP_POINT_X(pP), elemLen);
+ else {
+ sqrF(pQz, ECP_POINT_Z(pQ), pGFE);
+ mulF(pPtmp, ECP_POINT_X(pP), pQz, pGFE);
+ }
+ if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qx * Pz^2 */
+ cpGFpElementCopy(pQtmp, ECP_POINT_X(pQ), elemLen);
+ else {
+ sqrF(pPz, ECP_POINT_Z(pP), pGFE);
+ mulF(pQtmp, ECP_POINT_X(pQ), pPz, pGFE);
+ }
+ isEqu = GFP_EQ(pPtmp, pQtmp, elemLen);
+ }
+
+ if(isEqu) {
+ /* Py*Qz^3 ~ Qy*Pz^3 */
+ if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Py * Qz^3 */
+ cpGFpElementCopy(pPtmp, ECP_POINT_Y(pP), elemLen);
+ else {
+ mulF(pQz, ECP_POINT_Z(pQ), pQz, pGFE);
+ mulF(pPtmp, pQz, ECP_POINT_Y(pP), pGFE);
+ }
+ if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qy * Pz^3 */
+ cpGFpElementCopy(pQtmp, ECP_POINT_Y(pQ), elemLen);
+ else {
+ mulF(pPz, ECP_POINT_Z(pP), pPz, pGFE);
+ mulF(pQtmp, pPz, ECP_POINT_Y(pQ), pGFE);
+ }
+ isEqu = GFP_EQ(pPtmp, pQtmp, elemLen);
+ }
+
+ cpGFpReleasePool(4, pGFE);
+ return isEqu;
+ }
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_dblpoint.c b/ext/ipp/sources/ippcp/pcpgfpec_dblpoint.c
new file mode 100644
index 0000000..7cf8611
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_dblpoint.c
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_point_double()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+/*
+// A = 4*x*y^2
+// B = 3*x^2 + a*z^4
+//
+// x3 = -2*A + B^2
+// y3 = -8y^4 +B*(A-x3)
+// z3 = 2*y*z
+//
+// complexity: = 4s+4m (NIST's, SM2 curves)
+// = (EPID2 curve)
+// = 6s+4m (arbitrary curves)
+*/
+void gfec_point_double(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_add add = GFP_METHOD(pGFE)->add; /* gf add */
+ mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
+ mod_div2 div2= GFP_METHOD(pGFE)->div2; /* gf div2 */
+ mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
+ mod_mul3 mul3= GFP_METHOD(pGFE)->mul3; /* gf mul3 */
+ mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
+ mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
+
+ const BNU_CHUNK_T* pX = pPdata;
+ const BNU_CHUNK_T* pY = pPdata+elemLen;
+ const BNU_CHUNK_T* pZ = pPdata+2*+elemLen;
+
+ BNU_CHUNK_T* rX = pRdata;
+ BNU_CHUNK_T* rY = pRdata+elemLen;
+ BNU_CHUNK_T* rZ = pRdata+2*elemLen;
+
+ /* get temporary from top of EC point pool */
+ BNU_CHUNK_T* U = pEC->pPool;
+ BNU_CHUNK_T* M = U+elemLen;
+ BNU_CHUNK_T* S = M+elemLen;
+
+ mul2(S, pY, pGFE); /* S = 2*Y */
+ sqr(U, pZ, pGFE); /* U = Z^2 */
+
+ sqr(M, S, pGFE); /* M = 4*Y^2 */
+ mul(rZ, S, pZ, pGFE); /* Zres = 2*Y*Z */
+
+ sqr(rY, M, pGFE); /* Yres = 16*Y^4 */
+
+ mul(S, M, pX, pGFE); /* S = 4*X*Y^2 */
+ div2(rY, rY, pGFE); /* Yres = 8*Y^4 */
+
+ if(ECP_STD==ECP_SPECIFIC(pEC)) {
+ add(M, pX, U, pGFE); /* M = 3*(X^2-Z^4) */
+ sub(U, pX, U, pGFE);
+ mul(M, M, U, pGFE);
+ mul3(M, M, pGFE);
+ }
+ else {
+ sqr(M, pX, pGFE); /* M = 3*X^2 */
+ mul3(M, M, pGFE);
+ if(ECP_EPID2!=ECP_SPECIFIC(pEC)) {
+ sqr(U, U, pGFE); /* M = 3*X^2+a*Z4 */
+ mul(U, U, ECP_A(pEC), pGFE);
+ add(M, M, U, pGFE);
+ }
+ }
+
+ mul2(U, S, pGFE); /* U = 8*X*Y^2 */
+ sqr(rX, M, pGFE); /* Xres = M^2 */
+ sub(rX, rX, U, pGFE); /* Xres = M^2-U */
+
+ sub(S, S, rX, pGFE); /* S = 4*X*Y^2-Xres */
+ mul(S, S, M, pGFE); /* S = M*(4*X*Y^2-Xres) */
+ sub(rY, S, rY, pGFE); /* Yres = M*(4*X*Y^2-Xres) -8*Y^4 */
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_getpoint.c b/ext/ipp/sources/ippcp/pcpgfpec_getpoint.c
new file mode 100644
index 0000000..9cae2f6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_getpoint.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_GetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+/* returns 1/0 if point is finite/infinite */
+int gfec_GetPoint(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, const IppsGFpECPoint* pPoint, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ if( !IS_ECP_FINITE_POINT(pPoint) ) {
+ if(pX) cpGFpElementPadd(pX, elemLen, 0);
+ if(pY) cpGFpElementPadd(pY, elemLen, 0);
+ return 0;
+ }
+
+ /* affine point (1==Z) */
+ if( IS_ECP_AFFINE_POINT(pPoint) ) {
+ if(pX)
+ cpGFpElementCopy(pX, ECP_POINT_X(pPoint), elemLen);
+ if(pY)
+ cpGFpElementCopy(pY, ECP_POINT_Y(pPoint), elemLen);
+ return 1;
+ }
+
+ /* projective point (1!=Z) */
+ {
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
+
+ /* T = (1/Z)*(1/Z) */
+ BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pZinv = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pU = cpGFpGetPool(1, pGFE);
+ cpGFpxInv(pZinv, ECP_POINT_Z(pPoint), pGFE);
+ sqrF(pT, pZinv, pGFE);
+
+ if(pX) {
+ mulF(pU, ECP_POINT_X(pPoint), pT, pGFE);
+ cpGFpElementCopy(pX, pU, elemLen);
+ }
+ if(pY) {
+ mulF(pT, pZinv, pT, pGFE);
+ mulF(pU, ECP_POINT_Y(pPoint), pT, pGFE);
+ cpGFpElementCopy(pY, pU, elemLen);
+ }
+
+ cpGFpReleasePool(3, pGFE);
+ return 1;
+ }
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_makepoint.c b/ext/ipp/sources/ippcp/pcpgfpec_makepoint.c
new file mode 100644
index 0000000..80d43f7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_makepoint.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_MakePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+int gfec_MakePoint(IppsGFpECPoint* pPoint, const BNU_CHUNK_T* pElm, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGFE)->add;
+
+ BNU_CHUNK_T* pX = ECP_POINT_X(pPoint);
+ BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
+ BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint);
+
+ /* set x-coordinate */
+ cpGFpElementCopy(pX, pElm, elemLen);
+
+ /* T = X^3 + A*X + B */
+ sqrF(pY, pX, pGFE);
+ mulF(pY, pY, pX, pGFE);
+ if(ECP_SPECIFIC(pEC)!=ECP_EPID2) {
+ mulF(pZ, ECP_A(pEC), pX, pGFE);
+ addF(pY, pY, pZ, pGFE);
+ }
+ addF(pY, pY, ECP_B(pEC), pGFE);
+
+ /* set z-coordinate =1 */
+ cpGFpElementCopyPadd(pZ, elemLen, GFP_MNT_R(pGFE), elemLen);
+
+ /* Y = sqrt(Y) */
+ if( cpGFpSqrt(pY, pY, pGFE) ) {
+ ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
+ return 1;
+ }
+ else {
+ gfec_SetPointAtInfinity(pPoint);
+ return 0;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_mul.c b/ext/ipp/sources/ippcp/pcpgfpec_mul.c
new file mode 100644
index 0000000..095a634
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_mul.c
@@ -0,0 +1,138 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_MulPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+#include "pcpmask_ct.h"
+
+
+void gfec_point_mul(BNU_CHUNK_T* pRdata,
+ const BNU_CHUNK_T* pPdata,
+ const Ipp8u* pScalar8, int scalarBitSize,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
+{
+ int pointLen = ECP_POINTLEN(pEC);
+
+ /* optimal size of window */
+ const int window_size = 5;
+
+ /* aligned pre-computed table */
+ BNU_CHUNK_T* pTable = (BNU_CHUNK_T*)IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE);
+ setupTable(pTable, pPdata, pEC);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_neg negF = GFP_METHOD(pGFE)->neg;
+
+ BNU_CHUNK_T* pHy = cpGFpGetPool(1, pGFE);
+
+ BNU_CHUNK_T* pTdata = cpEcGFpGetPool(1, pEC); /* points from the pool */
+ BNU_CHUNK_T* pHdata = cpEcGFpGetPool(1, pEC);
+
+ int wvalue;
+ Ipp8u digit, sign;
+ int mask = (1<<(window_size+1)) -1;
+ int bit = scalarBitSize-(scalarBitSize%window_size);
+
+ /* first window */
+ if(bit) {
+ wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ }
+ else
+ wvalue = 0;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pTdata, pointLen, pTable, digit-1, 5-1);
+
+ for(bit-=window_size; bit>=window_size; bit-=window_size) {
+ gfec_point_double(pTdata, pTdata, pEC); /* probablyit's better to have separate calls */
+ gfec_point_double(pTdata, pTdata, pEC); /* instead of gfec_point_double_k() */
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+
+ wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTable, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+ }
+
+ /* last window */
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+
+ wvalue = *((Ipp16u*)&pScalar8[0]);
+ wvalue = (wvalue << 1) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTable, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+
+ cpGFpElementCopy(pRdata, pTdata, pointLen);
+
+ cpEcGFpReleasePool(2, pEC);
+ cpGFpReleasePool(1, pGFE);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_mul1.c b/ext/ipp/sources/ippcp/pcpgfpec_mul1.c
new file mode 100644
index 0000000..f06320a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_mul1.c
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_MulPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+IppsGFpECPoint* gfec_MulPoint(IppsGFpECPoint* pR,
+ const IppsGFpECPoint* pP,
+ const BNU_CHUNK_T* pScalar, int scalarLen,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
+{
+ FIX_BNU(pScalar, scalarLen);
+ {
+ gsModEngine* pGForder = ECP_MONT_R(pEC);
+
+ BNU_CHUNK_T* pTmpScalar = cpGFpGetPool(1, pGForder); /* length of scalar does not exceed length of order */
+ int orderBits = MOD_BITSIZE(pGForder);
+ int orderLen = MOD_LEN(pGForder);
+ cpGFpElementCopyPadd(pTmpScalar,orderLen+1, pScalar,scalarLen);
+
+ gfec_point_mul(ECP_POINT_X(pR), ECP_POINT_X(pP),
+ (Ipp8u*)pTmpScalar, orderBits,
+ pEC, pScratchBuffer);
+ cpGFpReleasePool(1, pGForder);
+
+ ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
+ return pR;
+ }
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_mulbase.c b/ext/ipp/sources/ippcp/pcpgfpec_mulbase.c
new file mode 100644
index 0000000..b715469
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_mulbase.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_base_point_mul()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+void gfec_base_point_mul(BNU_CHUNK_T* pRdata, const Ipp8u* pScalar8, int scalarBitSize, IppsGFpECState* pEC)
+{
+ /* size of window, get function and pre-computed table */
+ int window_size = ECP_PREMULBP(pEC)->w;
+ selectAP select_affine_point = ECP_PREMULBP(pEC)->select_affine_point;
+ const BNU_CHUNK_T* pTbl = ECP_PREMULBP(pEC)->pTbl;
+
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pGFE);
+
+ mod_neg negF = GFP_METHOD(pGFE)->neg;
+
+ BNU_CHUNK_T* mont1 = GFP_MNT_R(pGFE);
+
+ /* number of points per table slot */
+ int tslot_point = 1<<(window_size-1);
+ int tslot_size = tslot_point * (elmLen*2);
+
+ BNU_CHUNK_T* negtmp = cpGFpGetPool(1, pGFE); /* temporary element */
+ BNU_CHUNK_T* pointT = cpEcGFpGetPool(1, pEC); /* temporary point */
+
+ Ipp8u digit, sign;
+ int mask = (1<<(window_size+1)) -1;
+ int bit = 0;
+
+ /* processing of window[0] */
+ int wvalue = *((Ipp16u*)&pScalar8[0]);
+ wvalue = (wvalue << 1) & mask;
+
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ select_affine_point(pRdata, pTbl, digit);
+
+ negF(negtmp, pRdata+elmLen, pGFE);
+ cpMaskedReplace_ct(pRdata+elmLen, negtmp, elmLen, ~cpIsZero_ct(sign));
+ cpGFpElementCopy(pRdata+elmLen*2, mont1, elmLen);
+ cpGFpElementCopy(pointT+elmLen*2, mont1, elmLen);
+
+ /* processing of other windows.. [1],[2],... */
+ for(bit+=window_size, pTbl+=tslot_size; bit<=scalarBitSize; bit+=window_size, pTbl+=tslot_size) {
+ wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ select_affine_point(pointT, pTbl, digit);
+
+ negF(negtmp, pointT+elmLen, pGFE);
+ cpMaskedReplace_ct(pointT+elmLen, negtmp, elmLen, ~cpIsZero_ct(sign));
+
+ gfec_affine_point_add(pRdata, pRdata, pointT, pEC);
+ }
+
+ cpEcGFpReleasePool(1, pEC);
+ cpGFpReleasePool(1, pGFE);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_mulbase1.c b/ext/ipp/sources/ippcp/pcpgfpec_mulbase1.c
new file mode 100644
index 0000000..c73a756
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_mulbase1.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_MulBasePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+IppsGFpECPoint* gfec_MulBasePoint(IppsGFpECPoint* pR,
+ const BNU_CHUNK_T* pScalar, int scalarLen,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
+{
+ FIX_BNU(pScalar, scalarLen);
+ {
+ gsModEngine* pGForder = ECP_MONT_R(pEC);
+
+ BNU_CHUNK_T* pTmpScalar = cpGFpGetPool(1, pGForder); /* length of scalar does not exceed length of order */
+ int orderBits = MOD_BITSIZE(pGForder);
+ int orderLen = MOD_LEN(pGForder);
+ cpGFpElementCopyPadd(pTmpScalar,orderLen+1, pScalar,scalarLen);
+
+ if(ECP_PREMULBP(pEC))
+ gfec_base_point_mul(ECP_POINT_X(pR),
+ (Ipp8u*)pTmpScalar, orderBits,
+ pEC);
+ else
+ gfec_point_mul(ECP_POINT_X(pR), ECP_G(pEC),
+ (Ipp8u*)pTmpScalar, orderBits,
+ pEC, pScratchBuffer);
+ cpGFpReleasePool(1, pGForder);
+
+ ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
+ return pR;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_negpoint.c b/ext/ipp/sources/ippcp/pcpgfpec_negpoint.c
new file mode 100644
index 0000000..249a878
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_negpoint.c
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_NegPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+IppsGFpECPoint* gfec_NegPoint(IppsGFpECPoint* pR,
+ const IppsGFpECPoint* pP, IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pGFE);
+ if(pR!=pP)
+ gfec_CopyPoint(pR, pP, elmLen);
+ GFP_METHOD(pGFE)->neg(ECP_POINT_Y(pR), ECP_POINT_Y(pP), pGFE);
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_prod.c b/ext/ipp/sources/ippcp/pcpgfpec_prod.c
new file mode 100644
index 0000000..8acf3fb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_prod.c
@@ -0,0 +1,172 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_point_prod()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+#include "pcpmask_ct.h"
+
+
+void gfec_point_prod(BNU_CHUNK_T* pointR,
+ const BNU_CHUNK_T* pointA, const Ipp8u* scalarA,
+ const BNU_CHUNK_T* pointB, const Ipp8u* scalarB,
+ int scalarBitSize,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
+{
+ int pointLen = ECP_POINTLEN(pEC);
+
+ /* optimal size of window */
+ const int window_size = 5;
+ /* number of table entries */
+ const int tableLen = 1<<(window_size-1);
+
+ /* aligned pre-computed tables */
+ BNU_CHUNK_T* pTableA = (BNU_CHUNK_T*)IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE);
+ BNU_CHUNK_T* pTableB = pTableA+pointLen*tableLen;
+
+ setupTable(pTableA, pointA, pEC);
+ setupTable(pTableB, pointB, pEC);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_neg negF = GFP_METHOD(pGFE)->neg;
+
+ BNU_CHUNK_T* pHy = cpGFpGetPool(1, pGFE);
+
+ BNU_CHUNK_T* pTdata = cpEcGFpGetPool(1, pEC); /* points from the pool */
+ BNU_CHUNK_T* pHdata = cpEcGFpGetPool(1, pEC);
+
+ int wvalue;
+ Ipp8u digit, sign;
+ int mask = (1<<(window_size+1)) -1;
+ int bit = scalarBitSize-(scalarBitSize%window_size);
+
+ /* first window */
+ if(bit) {
+ wvalue = *((Ipp16u*)&scalarA[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ }
+ else
+ wvalue = 0;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pTdata, pointLen, pTableA, digit-1, 5-1);
+
+ if(bit) {
+ wvalue = *((Ipp16u*)&scalarB[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ }
+ else
+ wvalue = 0;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
+
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+
+ for(bit-=window_size; bit>=window_size; bit-=window_size) {
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+
+ wvalue = *((Ipp16u*)&scalarA[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTableA, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+
+ wvalue = *((Ipp16u*)&scalarB[(bit-1)/8]);
+ wvalue = (wvalue>> ((bit-1)%8)) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+ }
+ /* last window */
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+ gfec_point_double(pTdata, pTdata, pEC);
+
+ wvalue = *((Ipp16u*)&scalarA[0]);
+ wvalue = (wvalue << 1) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTableA, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+
+ wvalue = *((Ipp16u*)&scalarB[0]);
+ wvalue = (wvalue << 1) & mask;
+ booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
+ gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
+
+ negF(pHy, pHdata+elemLen, pGFE);
+ cpMaskedReplace_ct(pHdata+elemLen, pHy, elemLen, ~cpIsZero_ct(sign));
+ gfec_point_add(pTdata, pTdata, pHdata, pEC);
+
+ cpGFpElementCopy(pointR, pTdata, pointLen);
+
+ cpEcGFpReleasePool(2, pEC);
+ cpGFpReleasePool(1, pGFE);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_selectp192r1w7.c b/ext/ipp/sources/ippcp/pcpgfpec_selectp192r1w7.c
new file mode 100644
index 0000000..8cc40e5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_selectp192r1w7.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// p192r1_select_ap_w7()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// select affine point
+*/
+#if (_IPP32E < _IPP32E_M7)
+void p192r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
+{
+ #define OPERAND_BITSIZE (192)
+ #define LEN_P192 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
+ #define LEN_P192_APOINT (2*LEN_P192)
+
+ const int tblLen = 64;
+ int i;
+ unsigned int n;
+
+ /* clear output affine point */
+ for(n=0; n<LEN_P192_APOINT; n++)
+ pVal[n] = 0;
+
+ /* select poiint */
+ for(i=1; i<=tblLen; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(i, idx);
+ for(n=0; n<LEN_P192_APOINT; n++)
+ pVal[n] |= (pTbl[n] & mask);
+ pTbl += LEN_P192_APOINT;
+ }
+
+ #undef OPERAND_BITSIZE
+ #undef LEN_P192
+ #undef LEN_P192_APOINT
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_selectp224r1w7.c b/ext/ipp/sources/ippcp/pcpgfpec_selectp224r1w7.c
new file mode 100644
index 0000000..717dbda
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_selectp224r1w7.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// p224r1_select_ap_w7()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// select affine point
+*/
+#if (_IPP32E < _IPP32E_M7)
+void p224r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
+{
+ #define OPERAND_BITSIZE (224)
+ #define LEN_P224 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
+ #define LEN_P224_APOINT (2*LEN_P224)
+
+ const int tblLen = 64;
+ int i;
+ unsigned int n;
+
+ /* clear output affine point */
+ for(n=0; n<LEN_P224_APOINT; n++)
+ pVal[n] = 0;
+
+ /* select poiint */
+ for(i=1; i<=tblLen; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(i, idx);
+ for(n=0; n<LEN_P224_APOINT; n++)
+ pVal[n] |= (pTbl[n] & mask);
+ pTbl += LEN_P224_APOINT;
+ }
+
+ #undef OPERAND_BITSIZE
+ #undef LEN_P224
+ #undef LEN_P224_APOINT
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_selectp256r1w7.c b/ext/ipp/sources/ippcp/pcpgfpec_selectp256r1w7.c
new file mode 100644
index 0000000..a529f9a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_selectp256r1w7.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// p256r1_select_ap_w7()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// select affine point
+*/
+#if (_IPP32E < _IPP32E_M7)
+void p256r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
+{
+ #define OPERAND_BITSIZE (256)
+ #define LEN_P256 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
+ #define LEN_P256_APOINT (2*LEN_P256)
+
+ const int tblLen = 64;
+ int i;
+ unsigned int n;
+
+ /* clear output affine point */
+ for(n=0; n<LEN_P256_APOINT; n++)
+ pVal[n] = 0;
+
+ /* select poiint */
+ for(i=1; i<=tblLen; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(i, idx);
+ for(n=0; n<LEN_P256_APOINT; n++)
+ pVal[n] |= (pTbl[n] & mask);
+ pTbl += LEN_P256_APOINT;
+ }
+
+ #undef OPERAND_BITSIZE
+ #undef LEN_P256
+ #undef LEN_P256_APOINT
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_selectp384r1w5.c b/ext/ipp/sources/ippcp/pcpgfpec_selectp384r1w5.c
new file mode 100644
index 0000000..00385be
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_selectp384r1w5.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// p384r1_select_ap_w5()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// select affine point
+*/
+#if (_IPP32E < _IPP32E_M7)
+void p384r1_select_ap_w5(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
+{
+ #define OPERAND_BITSIZE (384)
+ #define LEN_P384 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
+ #define LEN_P384_APOINT (2*LEN_P384)
+
+ const int tblLen = 16;
+ int i;
+ unsigned int n;
+
+ /* clear output affine point */
+ for(n=0; n<LEN_P384_APOINT; n++)
+ pVal[n] = 0;
+
+ /* select poiint */
+ for(i=1; i<=tblLen; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(i, idx);
+ for(n=0; n<LEN_P384_APOINT; n++)
+ pVal[n] |= (pTbl[n] & mask);
+ pTbl += LEN_P384_APOINT;
+ }
+
+ #undef OPERAND_BITSIZE
+ #undef LEN_P384
+ #undef LEN_P384_APOINT
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_selectp521r1w5.c b/ext/ipp/sources/ippcp/pcpgfpec_selectp521r1w5.c
new file mode 100644
index 0000000..58abea1
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_selectp521r1w5.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// p521r1_select_ap_w5()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpmask_ct.h"
+
+/*
+// select affine point
+*/
+#if (_IPP32E < _IPP32E_M7)
+void p521r1_select_ap_w5(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
+{
+ #define OPERAND_BITSIZE (521)
+ #define LEN_P521 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
+ #define LEN_P521_APOINT (2*LEN_P521)
+
+ const int tblLen = 16;
+ int i;
+ unsigned int n;
+
+ /* clear output affine point */
+ for(n=0; n<LEN_P521_APOINT; n++)
+ pVal[n] = 0;
+
+ /* select point */
+ for(i=1; i<=tblLen; i++) {
+ BNU_CHUNK_T mask = cpIsEqu_ct(i, idx);
+ for(n=0; n<LEN_P521_APOINT; n++)
+ pVal[n] |= (pTbl[n] & mask);
+ pTbl += LEN_P521_APOINT;
+ }
+
+ #undef OPERAND_BITSIZE
+ #undef LEN_P521
+ #undef P521_POINT_AFFINE
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_setpoint.c b/ext/ipp/sources/ippcp/pcpgfpec_setpoint.c
new file mode 100644
index 0000000..f27105d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_setpoint.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_SetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+static int gfec_IsAffinePointAtInfinity(int ecInfinity,
+ const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY,
+ const IppsGFpState* pGF)
+{
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pGFE);
+
+ int atInfinity = GFP_IS_ZERO(pX,elmLen);
+
+ BNU_CHUNK_T* tmpY = cpGFpGetPool(1, pGFE);
+
+ /* set tmpY either:
+ // 0, if ec.b !=0
+ // mont(1) if ec.b ==0
+ */
+ cpGFpElementPadd(tmpY, elmLen, 0);
+ if(ecInfinity) {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
+ int basicElmLen = GFP_FELEN(pBasicGFE);
+ BNU_CHUNK_T* mont1 = GFP_MNT_R(pBasicGFE);
+ cpGFpElementCopyPadd(tmpY, elmLen, mont1, basicElmLen);
+ }
+
+ /* check if (x,y) represents point at infinity */
+ atInfinity &= GFP_EQ(pY, tmpY, elmLen);
+
+ cpGFpReleasePool(1, pGFE);
+ return atInfinity;
+}
+
+/* returns: 1/0 if set up finite/infinite point */
+int gfec_SetPoint(BNU_CHUNK_T* pPointData,
+ const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elmLen = GFP_FELEN(pGFE);
+
+ int finite_point= !gfec_IsAffinePointAtInfinity(ECP_INFINITY(pEC), pX, pY, pGF);
+ if(finite_point) {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
+ cpGFpElementCopy(pPointData, pX, elmLen);
+ cpGFpElementCopy(pPointData+elmLen, pY, elmLen);
+ cpGFpElementCopyPadd(pPointData+elmLen*2, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
+ }
+ else
+ cpGFpElementPadd(pPointData, 3*elmLen, 0);
+
+ return finite_point;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpec_setuptable.c b/ext/ipp/sources/ippcp/pcpgfpec_setuptable.c
new file mode 100644
index 0000000..8b51202
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpec_setuptable.c
@@ -0,0 +1,155 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// setupTable()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+/* sscm version */
+void setupTable(BNU_CHUNK_T* pTbl,
+ const BNU_CHUNK_T* pPdata,
+ IppsGFpECState* pEC)
+{
+ int pointLen = ECP_POINTLEN(pEC);
+ //int pointLen32 = pointLen*sizeof(BNU_CHUNK_T)/sizeof(ipp32u);
+
+ const int npoints = 3;
+ BNU_CHUNK_T* A = cpEcGFpGetPool(npoints, pEC);
+ BNU_CHUNK_T* B = A+pointLen;
+ BNU_CHUNK_T* C = B+pointLen;
+
+ // Table[0]
+ // Table[0] is implicitly (0,0,0) {point at infinity}, therefore no need to store it
+ // All other values are actually stored with an offset of -1
+
+ // Table[1] ( =[1]p )
+ //cpScatter32((Ipp32u*)pTbl, 16, 0, (Ipp32u*)pPdata, pointLen32);
+ gsScramblePut(pTbl, (1-1), pPdata, pointLen, (5-1));
+
+ // Table[2] ( =[2]p )
+ gfec_point_double(A, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 1, (Ipp32u*)A, pointLen32);
+ gsScramblePut(pTbl, (2-1), A, pointLen, (5-1));
+
+ // Table[3] ( =[3]p )
+ gfec_point_add(B, A, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 2, (Ipp32u*)B, pointLen32);
+ gsScramblePut(pTbl, (3-1), B, pointLen, (5-1));
+
+ // Table[4] ( =[4]p )
+ gfec_point_double(A, A, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 3, (Ipp32u*)A, pointLen32);
+ gsScramblePut(pTbl, (4-1), A, pointLen, (5-1));
+
+ // Table[5] ( =[5]p )
+ gfec_point_add(C, A, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 4, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (5-1), C, pointLen, (5-1));
+
+ // Table[10] ( =[10]p )
+ gfec_point_double(C, C, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 9, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (10-1), C, pointLen, (5-1));
+
+ // Table[11] ( =[11]p )
+ gfec_point_add(C, C, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 10, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (11-1), C, pointLen, (5-1));
+
+ // Table[6] ( =[6]p )
+ gfec_point_double(B, B, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 5, (Ipp32u*)B, pointLen32);
+ gsScramblePut(pTbl, (6-1), B, pointLen, (5-1));
+
+ // Table[7] ( =[7]p )
+ gfec_point_add(C, B, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 6, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (7-1), C, pointLen, (5-1));
+
+ // Table[14] ( =[14]p )
+ gfec_point_double(C, C, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 13, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (14-1), C, pointLen, (5-1));
+
+ // Table[15] ( =[15]p )
+ gfec_point_add(C, C, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 14, (Ipp32u*)C, pointLen32);
+ gsScramblePut(pTbl, (15-1), C, pointLen, (5-1));
+
+ // Table[12] ( =[12]p )
+ gfec_point_double(B, B, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 11, (Ipp32u*)B, pointLen32);
+ gsScramblePut(pTbl, (12-1), B, pointLen, (5-1));
+
+ // Table[13] ( =[13]p )
+ gfec_point_add(B, B, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 12, (Ipp32u*)B, pointLen32);
+ gsScramblePut(pTbl, (13-1), B, pointLen, (5-1));
+
+ // Table[8] ( =[8]p )
+ gfec_point_double(A, A, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 7, (Ipp32u*)A, pointLen32);
+ gsScramblePut(pTbl, (8-1), A, pointLen, (5-1));
+
+ // Table[9] ( =[9]p )
+ gfec_point_add(B, A, pPdata, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 8, (Ipp32u*)B, pointLen32);
+ gsScramblePut(pTbl, (9-1), B, pointLen, (5-1));
+
+ // Table[16] ( =[16]p )
+ gfec_point_double(A, A, pEC);
+ //cpScatter32((Ipp32u*)pTbl, 16, 15, (Ipp32u*)A, pointLen32);
+ gsScramblePut(pTbl, (16-1), A, pointLen, (5-1));
+
+ cpEcGFpReleasePool(npoints, pEC);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecaddpoint.c b/ext/ipp/sources/ippcp/pcpgfpecaddpoint.c
new file mode 100644
index 0000000..53f399b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecaddpoint.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECAddPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECAddPoint
+//
+// Purpose: Computes the sum of two points on an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pQ == NULL
+// pR == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pP->idCtx
+// invalid pQ->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+// ECP_POINT_FELEN(pQ)!=GFP_FELEN()
+// ECP_POINT_FELEN(pR)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the context of the first elliptic curve point
+// pQ Pointer to the context of the second elliptic curve point
+// pR Pointer to the context of the resulting elliptic curve point
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECAddPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECPoint* pR,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR4_RET(pP, pQ, pR, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pQ)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ if(pP==pQ)
+ gfec_DblPoint(pR, pP, pEC);
+ else
+ gfec_AddPoint(pR, pP, pQ, pEC);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbindstd192r1.c b/ext/ipp/sources/ippcp/pcpgfpecbindstd192r1.c
new file mode 100644
index 0000000..70f90e2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbindstd192r1.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECBindGxyTblStd192r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
+ const cpPrecompAP* preComp,
+ IppsGFpECState* pEC)
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elemLen = GFP_FELEN(pGFE);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
+
+ {
+ BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
+ int cmpFlag;
+ BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
+
+ selectAP select_affine_point = preComp->select_affine_point;
+ const BNU_CHUNK_T* pTbl = preComp->pTbl;
+ select_affine_point(pbp_tbl, pTbl, 1);
+
+ /* check if EC's and G-table's Base Point is the same */
+ cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
+
+ cpEcGFpReleasePool(1, pEC);
+
+ return cmpFlag? ippStsBadArgErr : ippStsNoErr;
+ }
+ }
+}
+
+/*F*
+// Name: ippsGFpECBindGxyTblStd192r1
+//
+// Purpose: Enables the use of base point-based pre-computed tables of EC192r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsBadArgErr pEC is not EC192r1
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECBindGxyTblStd192r1,(IppsGFpECState* pEC))
+{
+ IppStatus sts = cpGFpECBindGxyTbl(secp192r1_p, gfpec_precom_nistP192r1_fun(), pEC);
+
+ /* setup pre-computed g-table and point access function */
+ if(ippStsNoErr==sts)
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP192r1_fun();
+
+ return sts;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbindstd224r1.c b/ext/ipp/sources/ippcp/pcpgfpecbindstd224r1.c
new file mode 100644
index 0000000..744b6c3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbindstd224r1.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECBindGxyTblStd224r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
+ const cpPrecompAP* preComp,
+ IppsGFpECState* pEC)
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elemLen = GFP_FELEN(pGFE);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
+
+ {
+ BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
+ int cmpFlag;
+ BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
+
+ selectAP select_affine_point = preComp->select_affine_point;
+ const BNU_CHUNK_T* pTbl = preComp->pTbl;
+ select_affine_point(pbp_tbl, pTbl, 1);
+
+ /* check if EC's and G-table's Base Point is the same */
+ cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
+
+ cpEcGFpReleasePool(1, pEC);
+
+ return cmpFlag? ippStsBadArgErr : ippStsNoErr;
+ }
+ }
+}
+
+/*F*
+// Name: ippsGFpECBindGxyTblStd224r1
+//
+// Purpose: Enables the use of base point-based pre-computed tables of EC224r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsBadArgErr pEC is not EC224r1
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECBindGxyTblStd224r1,(IppsGFpECState* pEC))
+{
+ IppStatus sts = cpGFpECBindGxyTbl(secp224r1_p, gfpec_precom_nistP224r1_fun(), pEC);
+
+ /* setup pre-computed g-table and point access function */
+ if(ippStsNoErr==sts)
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP224r1_fun();
+
+ return sts;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbindstd256r1.c b/ext/ipp/sources/ippcp/pcpgfpecbindstd256r1.c
new file mode 100644
index 0000000..bfd2c7d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbindstd256r1.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECBindGxyTblStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
+ const cpPrecompAP* preComp,
+ IppsGFpECState* pEC)
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elemLen = GFP_FELEN(pGFE);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
+
+ {
+ BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
+ int cmpFlag;
+ BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
+
+ selectAP select_affine_point = preComp->select_affine_point;
+ const BNU_CHUNK_T* pTbl = preComp->pTbl;
+ select_affine_point(pbp_tbl, pTbl, 1);
+
+ /* check if EC's and G-table's Base Point is the same */
+ cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
+
+ cpEcGFpReleasePool(1, pEC);
+
+ return cmpFlag? ippStsBadArgErr : ippStsNoErr;
+ }
+ }
+}
+
+/*F*
+// Name: ippsGFpECBindGxyTblStd256r1
+//
+// Purpose: Enables the use of base point-based pre-computed tables of EC256r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsBadArgErr pEC is not EC256r1
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECBindGxyTblStd256r1,(IppsGFpECState* pEC))
+{
+ IppStatus sts = cpGFpECBindGxyTbl(secp256r1_p, gfpec_precom_nistP256r1_fun(), pEC);
+
+ /* setup pre-computed g-table and point access function */
+ if(ippStsNoErr==sts)
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP256r1_fun();
+
+ return sts;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbindstd384r1.c b/ext/ipp/sources/ippcp/pcpgfpecbindstd384r1.c
new file mode 100644
index 0000000..16cec1f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbindstd384r1.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECBindGxyTblStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
+ const cpPrecompAP* preComp,
+ IppsGFpECState* pEC)
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elemLen = GFP_FELEN(pGFE);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
+
+ {
+ BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
+ int cmpFlag;
+ BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
+
+ selectAP select_affine_point = preComp->select_affine_point;
+ const BNU_CHUNK_T* pTbl = preComp->pTbl;
+ select_affine_point(pbp_tbl, pTbl, 1);
+
+ /* check if EC's and G-table's Base Point is the same */
+ cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
+
+ cpEcGFpReleasePool(1, pEC);
+
+ return cmpFlag? ippStsBadArgErr : ippStsNoErr;
+ }
+ }
+}
+
+/*F*
+// Name: ippsGFpECBindGxyTblStd384r1
+//
+// Purpose: Enables the use of base point-based pre-computed tables of EC384r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsBadArgErr pEC is not EC384r1
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECBindGxyTblStd384r1,(IppsGFpECState* pEC))
+{
+ IppStatus sts = cpGFpECBindGxyTbl(secp384r1_p, gfpec_precom_nistP384r1_fun(), pEC);
+
+ /* setup pre-computed g-table and point access function */
+ if(ippStsNoErr==sts)
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP384r1_fun();
+
+ return sts;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbindstd521r1.c b/ext/ipp/sources/ippcp/pcpgfpecbindstd521r1.c
new file mode 100644
index 0000000..16d708d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbindstd521r1.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECBindGxyTblStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
+ const cpPrecompAP* preComp,
+ IppsGFpECState* pEC)
+{
+ IPP_BAD_PTR1_RET(pEC);
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elemLen = GFP_FELEN(pGFE);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
+
+ {
+ BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
+ int cmpFlag;
+ BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
+
+ selectAP select_affine_point = preComp->select_affine_point;
+ const BNU_CHUNK_T* pTbl = preComp->pTbl;
+ select_affine_point(pbp_tbl, pTbl, 1);
+
+ /* check if EC's and G-table's Base Point is the same */
+ cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
+
+ cpEcGFpReleasePool(1, pEC);
+
+ return cmpFlag? ippStsBadArgErr : ippStsNoErr;
+ }
+ }
+}
+
+/*F*
+// Name: ippsGFpECBindGxyTblStd521r1
+//
+// Purpose: Enables the use of base point-based pre-computed tables of EC521r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsBadArgErr pEC is not EC521r1
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECBindGxyTblStd521r1,(IppsGFpECState* pEC))
+{
+ IppStatus sts = cpGFpECBindGxyTbl(secp521r1_p, gfpec_precom_nistP521r1_fun(), pEC);
+
+ /* setup pre-computed g-table and point access function */
+ if(ippStsNoErr==sts)
+ ECP_PREMULBP(pEC) = gfpec_precom_nistP521r1_fun();
+
+ return sts;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecbufsize.c b/ext/ipp/sources/ippcp/pcpgfpecbufsize.c
new file mode 100644
index 0000000..ac89de9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecbufsize.c
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECScratchBufferSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpScratchBufferSize
+//
+// Purpose: Gets the size of the scratch buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pEC == NULL
+// pBufferSize == NULL
+// ippStsContextMatchErr invalid pEC->idCtx
+// ippStsBadArgErr 0>=nScalars
+// nScalars>6
+// ippStsNoErr no error
+//
+// Parameters:
+// nScalars Number of scalar values.
+// pEC Pointer to the context of the elliptic curve
+// pBufferSize Pointer to the calculated buffer size in bytes.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECScratchBufferSize,(int nScalars, const IppsGFpECState* pEC, int* pBufferSize))
+{
+ IPP_BAD_PTR2_RET(pEC, pBufferSize);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( (0>=nScalars)||(nScalars>IPP_MAX_EXPONENT_NUM), ippStsBadArgErr);
+
+ {
+ /* select constant size of window */
+ const int w = 5;
+ /* number of table entries */
+ const int nPrecomputed = 1<<(w-1); /* because of signed digit representation of scalar is uses */
+
+ int pointDataSize = ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T);
+
+ *pBufferSize = nScalars * pointDataSize*nPrecomputed + CACHE_LINE_SIZE;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpeccmppoint.c b/ext/ipp/sources/ippcp/pcpgfpeccmppoint.c
new file mode 100644
index 0000000..1b5027f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpeccmppoint.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECCmpPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECCmpPoint
+//
+// Purpose: Compares two points
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pQ == NULL
+// pEC == NULL
+// pResult == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pP->idCtx
+// invalid pQ->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+// ECP_POINT_FELEN(pQ)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the context of the first elliptic curve point
+// pQ Pointer to the context of the second elliptic curve point
+// pEC Pointer to the context of the elliptic curve
+// pResult Pointer to the result of the comparison
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECCmpPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ,
+ IppECResult* pResult,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR4_RET(pP, pQ, pResult, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pQ)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ *pResult = gfec_ComparePoint(pP, pQ, pEC)? ippECPointIsEqual : ippECPointIsNotEqual;
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpeccpypoint.c b/ext/ipp/sources/ippcp/pcpgfpeccpypoint.c
new file mode 100644
index 0000000..632e5b5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpeccpypoint.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECCpyPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECCpyPoint
+//
+// Purpose: Copies one point to another
+//
+// Returns: Reason:
+// ippStsNullPtrErr pA == NULL
+// pR == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pA)!=GFP_FELEN()
+// ECP_POINT_FELEN(pR)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the elliptic curve point being copied
+// pR Pointer to the context of the elliptic curve point being changed
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECCpyPoint,(const IppsGFpECPoint* pA,
+ IppsGFpECPoint* pR,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pA)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ gfec_CopyPoint(pR, pA, GFP_FELEN(GFP_PMA(ECP_GFP(pEC))));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecdh.c b/ext/ipp/sources/ippcp/pcpgfpecdh.c
new file mode 100644
index 0000000..d7b8c6f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecdh.c
@@ -0,0 +1,151 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECSharedSecretDH()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+
+
+
+
+/*F*
+// Name: ippsGFpECSharedSecretDHC
+//
+// Purpose: Compute Shared Secret (Diffie-Hellman)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivateA
+// NULL == pPublicB
+// NULL == pShare
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pPrivateA->idCtx
+// illegal pPublicB->idCtx
+// illegal pShare->idCtx
+//
+// ippStsRangeErr not enough room for share key
+//
+// ippStsShareKeyErr (infinity) => z
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivateA pointer to own private key
+// pPublicB pointer to alien public key
+// pShare pointer to the shared secret value
+// pEC pointer to the EC context
+// pScratchBuffer pointer to the scratch buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSharedSecretDH,(const IppsBigNumState* pPrivateA, const IppsGFpECPoint* pPublicB,
+ IppsBigNumState* pShare,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ /* test private (own) key */
+ IPP_BAD_PTR1_RET(pPrivateA);
+ pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr);
+
+ /* test public (other party) key */
+ IPP_BAD_PTR1_RET(pPublicB);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublicB), ippStsContextMatchErr );
+
+ /* test share secret value */
+ IPP_BAD_PTR1_RET(pShare);
+ pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pShare)<GFP_FELEN(pGFE)), ippStsRangeErr);
+
+ {
+ int elmLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elm;
+ IppsGFpECPoint T;
+ int finite_point;
+
+ /* T = [privateA]pPublicB */
+ cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
+ gfec_MulPoint(&T, pPublicB, BN_NUMBER(pPrivateA), BN_SIZE(pPrivateA), /*ECP_ORDBITSIZE(pEC),*/ pEC, pScratchBuffer);
+
+ /* share = T.x */
+ cpGFpElementConstruct(&elm, cpGFpGetPool(1, pGFE), elmLen);
+ finite_point = gfec_GetPoint(GFPE_DATA(&elm), NULL, &T, pEC);
+
+ if(finite_point) {
+ BNU_CHUNK_T* pShareData = BN_NUMBER(pShare);
+ int nsShare = BN_ROOM(pShare);
+ /* share = decode(T.x) */
+ GFP_METHOD(pGFE)->decode(pShareData, GFPE_DATA(&elm), pGFE);
+ cpGFpElementPadd(pShareData+elmLen, nsShare-elmLen, 0);
+
+ BN_SIGN(pShare) = ippBigNumPOS;
+ FIX_BNU(pShareData, nsShare);
+ BN_SIZE(pShare) = nsShare;
+ }
+
+ cpGFpReleasePool(1, pGFE);
+ cpEcGFpReleasePool(1, pEC);
+
+ return finite_point? ippStsNoErr : ippStsShareKeyErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecdhc.c b/ext/ipp/sources/ippcp/pcpgfpecdhc.c
new file mode 100644
index 0000000..d3b0dda
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecdhc.c
@@ -0,0 +1,163 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECSharedSecretDHC()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+
+
+/*F*
+// Name: ippsGFpECSharedSecretDHC
+//
+// Purpose: Compute Shared Secret (Diffie-Hellman with cofactor)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivateA
+// NULL == pPublicB
+// NULL == pShare
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pPrivateA->idCtx
+// illegal pPublicB->idCtx
+// illegal pShare->idCtx
+//
+// ippStsRangeErr not enough room for share key
+//
+// ippStsShareKeyErr (infinity) => z
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivateA pointer to own private key
+// pPublicB pointer to alien public key
+// pShare pointer to the shared secret value
+// pEC pointer to the EC context
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSharedSecretDHC,(const IppsBigNumState* pPrivateA, const IppsGFpECPoint* pPublicB,
+ IppsBigNumState* pShare,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ /* test private (own) key */
+ IPP_BAD_PTR1_RET(pPrivateA);
+ pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr);
+
+ /* test public (other party) key */
+ IPP_BAD_PTR1_RET(pPublicB);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublicB), ippStsContextMatchErr );
+
+ /* test share key */
+ IPP_BAD_PTR1_RET(pShare);
+ pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pShare)<GFP_FELEN(pGFE)), ippStsRangeErr);
+
+ {
+ int elmLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elm;
+ IppsGFpECPoint T;
+ int finite_point;
+
+ gsModEngine* montR = ECP_MONT_R(pEC);
+ int nsR = MOD_LEN(montR);
+
+ BNU_CHUNK_T* F = cpGFpGetPool(2, pGFE);
+
+ /* compute factored secret F = coFactor*privateA */
+ BNU_CHUNK_T* pCofactor = ECP_COFACTOR(pEC);
+ int cofactorLen = GFP_FELEN(pGFE);
+ cofactorLen = cpGFpElementLen(pCofactor, cofactorLen);
+
+ if(GFP_IS_ONE(pCofactor, cofactorLen))
+ cpGFpElementCopyPadd(F, nsR, BN_NUMBER(pPrivateA), BN_SIZE(pPrivateA));
+ else {
+ cpMontEnc_BNU_EX(F, BN_NUMBER(pPrivateA), BN_SIZE(pPrivateA), montR);
+ cpMontMul_BNU_EX(F, F, nsR, pCofactor, cofactorLen, montR);
+ }
+ /* T = [F]pPublicB */
+ cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
+ gfec_MulPoint(&T, pPublicB, F, nsR, /*ECP_ORDBITSIZE(pEC),*/ pEC, pScratchBuffer);
+
+ /* share = T.x */
+ cpGFpElementConstruct(&elm, F, elmLen);
+ finite_point = gfec_GetPoint(GFPE_DATA(&elm), NULL, &T, pEC);
+ if(finite_point) {
+ BNU_CHUNK_T* pShareData = BN_NUMBER(pShare);
+ int nsShare = BN_ROOM(pShare);
+ /* share = decode(T.x) */
+ GFP_METHOD(pGFE)->decode(pShareData, GFPE_DATA(&elm), pGFE);
+ cpGFpElementPadd(pShareData+elmLen, nsShare-elmLen, 0);
+
+ BN_SIGN(pShare) = ippBigNumPOS;
+ FIX_BNU(pShareData, nsShare);
+ BN_SIZE(pShare) = nsShare;
+ }
+
+ cpGFpReleasePool(2, pGFE);
+ cpEcGFpReleasePool(1, pEC);
+
+ return finite_point? ippStsNoErr : ippStsShareKeyErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecessm2.h b/ext/ipp/sources/ippcp/pcpgfpecessm2.h
new file mode 100644
index 0000000..543f680
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecessm2.h
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// ES encryption/decryption API
+//
+//
+*/
+
+#if !defined(_CP_GFP_ES_SM2_H)
+#define _CP_GFP_ES_SM2_H
+
+#include "owncp.h"
+
+typedef enum {
+ ECESAlgoInit,
+ ECESAlgoKeySet,
+ ECESAlgoProcessing,
+ ECESAlgoFinished
+} ECESAlgoState;
+
+struct _cpStateECES_SM2 {
+ IppCtxId idCtx;
+ Ipp8u* pSharedSecret;
+ Ipp32s sharedSecretLen;
+
+ ECESAlgoState state;
+
+ Ipp32u kdfCounter;
+ Ipp8u pKdfWindow[IPP_SM3_DIGEST_BITSIZE / BYTESIZE];
+ Ipp8u wasNonZero;
+ Ipp8u kdfIndex;
+
+ IppsHashState_rmf* pKdfHasher;
+ IppsHashState_rmf* pTagHasher;
+};
+
+/* get a byte, update 0-kdf status */
+__INLINE Ipp8u cpECES_SM2KdfNextByte(IppsECESState_SM2* pState) {
+ if (pState->kdfIndex == IPP_SM3_DIGEST_BITSIZE / BYTESIZE) {
+ ++pState->kdfCounter;
+ pState->kdfIndex = 0;
+
+ {
+ Ipp8u ctnStr[sizeof(Ipp32u)];
+ ippsHashUpdate_rmf(pState->pSharedSecret, pState->sharedSecretLen, pState->pKdfHasher);
+ U32_TO_HSTRING(ctnStr, pState->kdfCounter);
+ ippsHashUpdate_rmf(ctnStr, sizeof(Ipp32u), pState->pKdfHasher);
+ ippsHashFinal_rmf(pState->pKdfWindow, pState->pKdfHasher);
+ }
+ }
+
+ pState->wasNonZero |= pState->pKdfWindow[pState->kdfIndex];
+
+ return pState->pKdfWindow[pState->kdfIndex++];
+}
+
+#endif \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpgfpecget.c b/ext/ipp/sources/ippcp/pcpgfpecget.c
new file mode 100644
index 0000000..9ae74d9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecget.c
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECGet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECGet
+//
+// Purpose: Extracts the parameters of an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pA->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pA)!=GFP_FELEN(pGFE)
+// GFPE_ROOM(pB)!=GFP_FELEN(pGFE)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// ppGFp Pointer to the pointer to the context of underlying finite field
+// pA Pointer to a copy of the coefficient A of the equation defining the elliptic curve
+// pB Pointer to a copy of the coefficient B of the equation defining the elliptic curve
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECGet,(IppsGFpState** const ppGFp,
+ IppsGFpElement* pA, IppsGFpElement* pB,
+ const IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ {
+ const IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elementSize = GFP_FELEN(pGFE);
+
+ if(ppGFp) {
+ *ppGFp = (IppsGFpState*)pGF;
+ }
+
+ if(pA) {
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ cpGFpElementCopy(GFPE_DATA(pA), ECP_A(pEC), elementSize);
+ }
+ if(pB) {
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+ IPP_BADARG_RET( GFPE_ROOM(pB)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ cpGFpElementCopy(GFPE_DATA(pB), ECP_B(pEC), elementSize);
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecgetpoint.c b/ext/ipp/sources/ippcp/pcpgfpecgetpoint.c
new file mode 100644
index 0000000..ad3235f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecgetpoint.c
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECGetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECGetPoint
+//
+// Purpose: Retrieves coordinates of a point on an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+// pX != NULL && invalid pX->idCtx
+// pY != NULL && invalid pY->idCtx
+// pX != NULL && GFPE_ROOM(pX)!=GFP_FELEN()
+// pY != NULL && GFPE_ROOM(pY)!=GFP_FELEN()
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+// pX != NULL && GFPE_ROOM(pX)!=GFP_FELEN()
+// pY != NULL && GFPE_ROOM(pY)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pX, pY Pointers to the X and Y coordinates of a point on the elliptic curve
+//
+// Note:
+// Is not a fact that computed point belongs to BP-related subgroup BP
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECGetPoint,(const IppsGFpECPoint* pPoint,
+ IppsGFpElement* pX, IppsGFpElement* pY,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( pX && !GFPE_TEST_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( pY && !GFPE_TEST_ID(pY), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( pX && GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( pY && GFPE_ROOM(pY)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ /* returns (X,Y) == (0,0) if Point is at infinity */
+ gfec_GetPoint((pX)? GFPE_DATA(pX):NULL, (pY)? GFPE_DATA(pY):NULL, pPoint, pEC);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecgetpointoctstring.c b/ext/ipp/sources/ippcp/pcpgfpecgetpointoctstring.c
new file mode 100644
index 0000000..a47ec18
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecgetpointoctstring.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECGetPointOctString()
+//
+*/
+#include "pcpgfpecessm2.h"
+#include "pcpgfpecstuff.h"
+
+/*F*
+// Name: ippsGFpECGetPointOctString
+//
+// Purpose: Converts a point on EC into x||y octstring
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL / pEC == NULL / pStr == NULL
+// ippStsContextMatchErr pEC, pPoint invalid context
+// ippStsNotSupportedModeErr pGFE->extdegree > 1
+// ippStsSizeErr strLen is not equal to double GFp element
+// ippStsOutOfRangeErr the point does not belong to the EC
+// ippStsPointAtInfinity a point on infinity cannot be converted to a string
+// ippStsNoErr no errors
+//
+// Parameters:
+// pStr pointer to the string to read from
+// strLen length of the string
+// pPoint pointer to output point
+// pEC EC ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECGetPointOctString, (const IppsGFpECPoint* pPoint,
+ Ipp8u* pStr, int strLen, IppsGFpECState* pEC)) {
+ IPP_BAD_PTR3_RET(pPoint, pEC, pStr);
+ IPP_BADARG_RET(pPoint->idCtx != idCtxGFPPoint, ippStsContextMatchErr);
+ IPP_BADARG_RET(pEC->idCtx != idCtxGFPEC, ippStsContextMatchErr);
+ IPP_BADARG_RET(!pEC->subgroup, ippStsContextMatchErr);
+ IPP_BADARG_RET(1 < pEC->pGF->pGFE->extdegree, ippStsNotSupportedModeErr);
+
+ {
+ gsModEngine* pGFE = pEC->pGF->pGFE;
+ int elemLen = BITS2WORD8_SIZE(pGFE->modBitLen);
+ IPP_BADARG_RET(strLen != elemLen * 2, ippStsSizeErr);
+ IPP_BADARG_RET(pPoint->elementSize != pGFE->modLen, ippStsOutOfRangeErr);
+
+ {
+ int finitePoint;
+ IppsGFpElement ptX, ptY;
+
+ cpGFpElementConstruct(&ptX, cpGFpGetPool(1, pGFE), pGFE->modLen);
+ cpGFpElementConstruct(&ptY, cpGFpGetPool(1, pGFE), pGFE->modLen);
+ finitePoint = gfec_GetPoint(ptX.pData, ptY.pData, pPoint, pEC);
+ if (finitePoint) {
+ ippsGFpGetElementOctString(&ptX, pStr, elemLen, pEC->pGF);
+ pStr += elemLen;
+ ippsGFpGetElementOctString(&ptY, pStr, elemLen, pEC->pGF);
+ }
+
+ cpGFpReleasePool(2, pGFE); /* release ptX and ptY from the pool */
+
+ return finitePoint ? ippStsNoErr : ippStsPointAtInfinity;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecgetpointreg.c b/ext/ipp/sources/ippcp/pcpgfpecgetpointreg.c
new file mode 100644
index 0000000..b495211
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecgetpointreg.c
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECGetPointRegular()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECGetPointRegular
+//
+// Purpose: Retrieves coordinates of a point on an elliptic curve in the regular domain
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+//
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+// invalid pX->idCtx
+// invalid pY->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+// BN_ROOM(pX)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE))
+// BN_ROOM(pY)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE))
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pX, pY Pointers to the X and Y coordinates of a point on the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECGetPointRegular,(const IppsGFpECPoint* pPoint,
+ IppsBigNumState* pX, IppsBigNumState* pY,
+ IppsGFpECState* pEC))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ if(pX) {
+ pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET(BN_ROOM(pX)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE), ippStsOutOfRangeErr);
+ }
+ if(pY) {
+ pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr );
+ IPP_BADARG_RET(BN_ROOM(pY)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE), ippStsOutOfRangeErr);
+ }
+
+ {
+ int elmLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* x = cpGFpGetPool(2, pGFE);
+ BNU_CHUNK_T* y = x + elmLen;
+
+ /* returns (X,Y) == (0,0) if Point is at infinity */
+ gfec_GetPoint((pX)? x:NULL, (pY)? y:NULL, pPoint, pEC);
+
+ /* convert into refular domain */
+ if(pX) {
+ GFP_METHOD(pGFE)->decode(x, x, pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)x, pX);
+ }
+ if(pY) {
+ GFP_METHOD(pGFE)->decode(y, y, pGFE);
+ ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)y, pY);
+ }
+
+ cpGFpReleasePool(2, pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecgetsize.c b/ext/ipp/sources/ippcp/pcpgfpecgetsize.c
new file mode 100644
index 0000000..f3caa07
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecgetsize.c
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECGetSize
+//
+// Purpose: Gets the size of an elliptic curve over the finite field
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pSize
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pSize Buffer size in bytes needed for the IppsGFpECState context
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECGetSize,(const IppsGFpState* pGFp, int* pSize))
+{
+ IPP_BAD_PTR2_RET(pGFp, pSize);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ *pSize = cpGFpECGetSize(cpGFpBasicDegreeExtension(pGFE), GFP_FEBITLEN(cpGFpBasic(pGFE)))
+ + ECGFP_ALIGNMENT;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecgetsubgroup.c b/ext/ipp/sources/ippcp/pcpgfpecgetsubgroup.c
new file mode 100644
index 0000000..06568f8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecgetsubgroup.c
@@ -0,0 +1,147 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECGetSubgroup()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECGet
+//
+// Purpose: Extracts the parameters (base point and its order) of an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// NULL == pEC->subgroup
+// invalid pX->idCtx
+// invalid pY->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pX)!=GFP_FELEN(pGFE)
+// GFPE_ROOM(pY)!=GFP_FELEN(pGFE)
+//
+// ippStsLengthErr BN_ROOM(pOrder) < orderLen
+// BN_ROOM(pCofactor) < cofactorLen
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// ppGFp Pointer to the pointer to the context of underlying finite field
+// pX, pY Pointers to the X and Y coordinates of the base point of the elliptic curve
+// pOrder Pointer to the big number context storing the order of the base point.
+// pCofactor Pointer to the big number context storing the cofactor.
+// pEC Pointer to the context of the elliptic curve.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECGetSubgroup,(IppsGFpState** const ppGFp,
+ IppsGFpElement* pX, IppsGFpElement* pY,
+ IppsBigNumState* pOrder,
+ IppsBigNumState* pCofactor,
+ const IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ {
+ const IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ Ipp32u elementSize = GFP_FELEN(pGFE);
+
+ if(ppGFp) {
+ *ppGFp = (IppsGFpState*)pGF;
+ }
+
+ if(pX) {
+ IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ cpGFpElementCopy(GFPE_DATA(pX), ECP_G(pEC), elementSize);
+ }
+ if(pY) {
+ IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
+ IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ cpGFpElementCopy(GFPE_DATA(pY), ECP_G(pEC)+elementSize, elementSize);
+ }
+
+ if(pOrder) {
+ BNU_CHUNK_T* pOrderData = MOD_MODULUS(ECP_MONT_R(pEC));
+ int orderBitSize = ECP_ORDBITSIZE(pEC);
+ int orderLen = BITS_BNU_CHUNK(orderBitSize);
+ FIX_BNU(pOrderData, orderLen);
+
+ pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_ROOM(pOrder) < orderLen, ippStsLengthErr);
+
+ ZEXPAND_COPY_BNU(BN_NUMBER(pOrder), BN_ROOM(pOrder), pOrderData, orderLen);
+ BN_SIZE(pOrder) = orderLen;
+ BN_SIGN(pOrder) = ippBigNumPOS;
+ }
+
+ if(pCofactor) {
+ BNU_CHUNK_T* pCofactorData = ECP_COFACTOR(pEC);
+ int cofactorLen = elementSize;
+ FIX_BNU(pCofactorData, cofactorLen);
+
+ pCofactor = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCofactor, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pCofactor), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_ROOM(pCofactor) < cofactorLen, ippStsLengthErr);
+
+ ZEXPAND_COPY_BNU(BN_NUMBER(pCofactor), BN_ROOM(pCofactor), pCofactorData, cofactorLen);
+ BN_SIZE(pCofactor) = cofactorLen;
+ BN_SIGN(pCofactor) = ippBigNumPOS;
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinit.c b/ext/ipp/sources/ippcp/pcpgfpecinit.c
new file mode 100644
index 0000000..8d12a67
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinit.c
@@ -0,0 +1,146 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECInit
+//
+// Purpose: Initializes the context of an elliptic curve over a finite field.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pA
+// NULL == pB
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pA->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pA)!=GFP_FELEN(pGFE)
+// GFPE_ROOM(pB)!=GFP_FELEN(pGFE)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pA Pointer to the coefficient A of the equation defining the elliptic curve
+// pB Pointer to the coefficient B of the equation defining the elliptic curve
+// pEC Pointer to the context of the elliptic curve being initialized
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInit,(const IppsGFpState* pGFp,
+ const IppsGFpElement* pA, const IppsGFpElement* pB,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ {
+ Ipp8u* ptr = (Ipp8u*)pEC;
+
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ int elemLen = GFP_FELEN(pGFE);
+
+ int maxOrderBits = 1+ cpGFpBasicDegreeExtension(pGFE) * GFP_FEBITLEN(cpGFpBasic(pGFE)); /* Hasse's theorem */
+ #if defined(_LEGACY_ECCP_SUPPORT_)
+ int maxOrdLen = BITS_BNU_CHUNK(maxOrderBits);
+ #endif
+
+ int modEngineCtxSize;
+ gsModEngineGetSize(maxOrderBits, MONT_DEFAULT_POOL_LENGTH, &modEngineCtxSize);
+
+ ECP_ID(pEC) = idCtxGFPEC;
+ ECP_GFP(pEC) = (IppsGFpState*)(IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT));
+ ECP_SUBGROUP(pEC) = 0;
+ ECP_POINTLEN(pEC) = elemLen*3;
+ ECP_ORDBITSIZE(pEC) = maxOrderBits;
+ ECP_SPECIFIC(pEC) = ECP_ARB;
+
+ ptr += sizeof(IppsGFpECState);
+ ECP_A(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
+ ECP_B(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
+ ECP_G(pEC) = (BNU_CHUNK_T*)(ptr); ptr += ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T);
+ ECP_PREMULBP(pEC) = (cpPrecompAP*)NULL;
+ ECP_MONT_R(pEC) = (gsModEngine*)( IPP_ALIGNED_PTR((ptr), (MONT_ALIGNMENT)) ); ptr += modEngineCtxSize;
+ ECP_COFACTOR(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
+ #if defined(_LEGACY_ECCP_SUPPORT_)
+ ECP_PUBLIC(pEC) = (BNU_CHUNK_T*)(ptr); ptr += 3*elemLen*sizeof(BNU_CHUNK_T);
+ ECP_PUBLIC_E(pEC) = (BNU_CHUNK_T*)(ptr); ptr += 3*elemLen*sizeof(BNU_CHUNK_T);
+ ECP_PRIVAT(pEC) = (BNU_CHUNK_T*)(ptr); ptr += maxOrdLen*sizeof(BNU_CHUNK_T);
+ ECP_PRIVAT_E(pEC) = (BNU_CHUNK_T*)(ptr); ptr += maxOrdLen*sizeof(BNU_CHUNK_T);
+ ECP_SBUFFER(pEC) = (BNU_CHUNK_T*)0;
+ #endif
+ ECP_POOL(pEC) = (BNU_CHUNK_T*)(ptr); //ptr += ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T)*EC_POOL_SIZE;
+
+ cpGFpElementPadd(ECP_A(pEC), elemLen, 0);
+ cpGFpElementPadd(ECP_B(pEC), elemLen, 0);
+ cpGFpElementPadd(ECP_G(pEC), elemLen*3, 0);
+ //gsModEngineInit(ECP_MONT_R(pEC), NULL, maxOrderBits, MONT_DEFAULT_POOL_LENGTH, gsModArithMont());
+ gsModEngineInit(ECP_MONT_R(pEC), NULL, maxOrderBits, MONT_DEFAULT_POOL_LENGTH, NULL);
+
+ cpGFpElementPadd(ECP_COFACTOR(pEC), elemLen, 0);
+
+ cpGFpElementPadd(ECP_POOL(pEC), elemLen*3*EC_POOL_SIZE, 0);
+
+ /* set up EC if possible */
+ if(pA && pB)
+ return ippsGFpECSet(pA,pB, pEC);
+ else
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd128r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd128r1.c
new file mode 100644
index 0000000..29afc67
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd128r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd128r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd128r1
+//
+// Purpose: Initializes the context of EC128r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd128r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp128r1_p, BITS_BNU_CHUNK(128), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(128)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(128), secp128r1_a,
+ BITS_BNU_CHUNK(128), secp128r1_b,
+ BITS_BNU_CHUNK(128), secp128r1_gx,
+ BITS_BNU_CHUNK(128), secp128r1_gy,
+ BITS_BNU_CHUNK(128), secp128r1_r,
+ secp128r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd128r2.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd128r2.c
new file mode 100644
index 0000000..d123a1e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd128r2.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd128r2()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd128r2
+//
+// Purpose: Initializes the context of EC128r2
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd128r2,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp128r2_p, BITS_BNU_CHUNK(128), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(128)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(128), secp128r2_a,
+ BITS_BNU_CHUNK(128), secp128r2_b,
+ BITS_BNU_CHUNK(128), secp128r2_gx,
+ BITS_BNU_CHUNK(128), secp128r2_gy,
+ BITS_BNU_CHUNK(128), secp128r2_r,
+ secp128r2_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd192r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd192r1.c
new file mode 100644
index 0000000..e5c61e8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd192r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd192r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd192r1
+//
+// Purpose: Initializes the context of EC192r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd192r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp192r1_p, BITS_BNU_CHUNK(192), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(192)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(192), secp192r1_a,
+ BITS_BNU_CHUNK(192), secp192r1_b,
+ BITS_BNU_CHUNK(192), secp192r1_gx,
+ BITS_BNU_CHUNK(192), secp192r1_gy,
+ BITS_BNU_CHUNK(192), secp192r1_r,
+ secp192r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd224r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd224r1.c
new file mode 100644
index 0000000..e6a9b2c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd224r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd224r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd224r1
+//
+// Purpose: Initializes the context of EC224r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd224r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp224r1_p, BITS_BNU_CHUNK(224), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(224)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(224), secp224r1_a,
+ BITS_BNU_CHUNK(224), secp224r1_b,
+ BITS_BNU_CHUNK(224), secp224r1_gx,
+ BITS_BNU_CHUNK(224), secp224r1_gy,
+ BITS_BNU_CHUNK(224), secp224r1_r,
+ secp224r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd256r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd256r1.c
new file mode 100644
index 0000000..b86bd19
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd256r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd256r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd256r1
+//
+// Purpose: Initializes the context of EC256r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd256r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp256r1_p, BITS_BNU_CHUNK(256), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(256)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(256), secp256r1_a,
+ BITS_BNU_CHUNK(256), secp256r1_b,
+ BITS_BNU_CHUNK(256), secp256r1_gx,
+ BITS_BNU_CHUNK(256), secp256r1_gy,
+ BITS_BNU_CHUNK(256), secp256r1_r,
+ secp256r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd384r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd384r1.c
new file mode 100644
index 0000000..8853464
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd384r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd384r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd384r1
+//
+// Purpose: Initializes the context of EC384r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd384r1,(const IppsGFpState* pGFp, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGFp, pEC);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp384r1_p, BITS_BNU_CHUNK(384), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(384)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGFp, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(384), secp384r1_a,
+ BITS_BNU_CHUNK(384), secp384r1_b,
+ BITS_BNU_CHUNK(384), secp384r1_gx,
+ BITS_BNU_CHUNK(384), secp384r1_gy,
+ BITS_BNU_CHUNK(384), secp384r1_r,
+ secp384r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstd521r1.c b/ext/ipp/sources/ippcp/pcpgfpecinitstd521r1.c
new file mode 100644
index 0000000..7b704ce
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstd521r1.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStd521r1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStd521r1
+//
+// Purpose: Initializes the context of EC521r1
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStd521r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGF, pEC);
+
+ pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGF);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(secp521r1_p, BITS_BNU_CHUNK(521), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(521)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGF, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(521), secp521r1_a,
+ BITS_BNU_CHUNK(521), secp521r1_b,
+ BITS_BNU_CHUNK(521), secp521r1_gx,
+ BITS_BNU_CHUNK(521), secp521r1_gy,
+ BITS_BNU_CHUNK(521), secp521r1_r,
+ secp521r1_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecinitstdbn256.c b/ext/ipp/sources/ippcp/pcpgfpecinitstdbn256.c
new file mode 100644
index 0000000..6b32a41
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecinitstdbn256.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECInitStdBN256()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+
+
+
+static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
+ int bLen, const BNU_CHUNK_T* pB,
+ int xLen, const BNU_CHUNK_T* pX,
+ int yLen, const BNU_CHUNK_T* pY,
+ int rLen, const BNU_CHUNK_T* pR,
+ BNU_CHUNK_T h,
+ IppsGFpECState* pEC)
+{
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IppsGFpElement elmA, elmB;
+ IppsBigNumState R, H;
+
+ /* convert A ans B coeffs into GF elements */
+ cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
+ cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
+ ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
+ /* and set EC */
+ ippsGFpECSet(&elmA, &elmB, pEC);
+
+ /* construct R and H */
+ cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
+ cpConstructBN(&H, 1, &h, NULL);
+ /* convert GX ans GY coeffs into GF elements */
+ ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
+ ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
+ /* and init EC subgroup */
+ ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
+}
+
+/*F*
+// Name: ippsGFpECInitStdBN256
+//
+// Purpose: Initializes the context of ECBN256
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pGFp
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+//
+// ippStsBadArgErr pGFp does not specify the finite field over which the given
+// standard elliptic curve is defined
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGFp Pointer to the IppsGFpState context of the underlying finite field
+// pEC Pointer to the context of the elliptic curve being initialized.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECInitStdBN256,(const IppsGFpState* pGF, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pGF, pEC);
+
+ pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGF);
+
+ /* test if GF is prime GF */
+ IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ /* test underlying prime value*/
+ IPP_BADARG_RET(cpCmp_BNU(tpmBN_p256p_p, BITS_BNU_CHUNK(256), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(256)), ippStsBadArgErr);
+
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+
+ ippsGFpECInit(pGF, NULL, NULL, pEC);
+ cpGFpECSetStd(BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_a,
+ BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_b,
+ BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_gx,
+ BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_gy,
+ BITS_BNU_CHUNK(256), tpmBN_p256p_r,
+ tpmBN_p256p_h,
+ pEC);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpeckeys.c b/ext/ipp/sources/ippcp/pcpgfpeckeys.c
new file mode 100644
index 0000000..d57cbfd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpeckeys.c
@@ -0,0 +1,152 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECTstKeyPair()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+
+
+/*F*
+// Name: ippsGFpECTstKeyPair
+//
+// Purpose: Test Key Pair
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivate
+// NULL == pPublic
+// NULL == pResult
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pPrivate->idCtx
+// illegal pPublic->idCtx
+//
+// ippStsRangeErr ECP_POINT_FELEN(pPublic)<GFP_FELEN()
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivate pointer to the private key
+// pPublic pointer to the public key
+// pResult pointer to the result:
+// ippECValid/ippECInvalidPrivateKey/ippECPointIsAtInfinite/ippECInvalidPublicKey
+// pEC pointer to the EC context
+// pScratchBuffer pointer to buffer (1 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECTstKeyPair, (const IppsBigNumState* pPrivate, const IppsGFpECPoint* pPublic, IppECResult* pResult,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+{
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ /* test result */
+ IPP_BAD_PTR1_RET(pResult);
+ *pResult = ippECValid;
+
+ /* private key validation request */
+ if( pPrivate ) {
+ pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
+
+ {
+ BNU_CHUNK_T* pS = BN_NUMBER(pPrivate);
+ int nsS = BN_SIZE(pPrivate);
+
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
+ int orderLen = BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC));
+
+ /* check private key */
+ if(cpEqu_BNU_CHUNK(pS, nsS, 0) || 0<=cpCmp_BNU(pS, nsS, pOrder, orderLen)) {
+ *pResult = ippECInvalidPrivateKey;
+ return ippStsNoErr;
+ }
+ }
+ }
+
+ /* public key validation request */
+ if( pPublic ) {
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublic), ippStsContextMatchErr );
+ IPP_BADARG_RET(ECP_POINT_FELEN(pPublic)<GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsRangeErr);
+
+ {
+ IppsGFpECPoint T;
+ cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
+
+ do {
+ /* public != point_at_Infinity */
+ if( gfec_IsPointAtInfinity(pPublic) ) {
+ *pResult = ippECPointIsAtInfinite;
+ break;
+ }
+ /* order*public == point_at_Infinity */
+ gfec_MulPoint(&T, pPublic, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), /*0,*/ pEC, pScratchBuffer);
+ if( !gfec_IsPointAtInfinity(&T) ) {
+ *pResult = ippECInvalidPublicKey;
+ break;
+ }
+ /* addition test: private*BasePoint == public */
+ if(pPrivate) {
+ gfec_MulBasePoint(&T, BN_NUMBER(pPrivate), BN_SIZE(pPrivate), pEC, pScratchBuffer);
+ if(!gfec_ComparePoint(&T, pPublic, pEC))
+ *pResult = ippECInvalidKeyPair;
+ }
+ } while(0);
+
+ cpEcGFpReleasePool(1, pEC);
+ }
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecmakepoint.c b/ext/ipp/sources/ippcp/pcpgfpecmakepoint.c
new file mode 100644
index 0000000..607d0a6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecmakepoint.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECMakePoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+
+/*
+ computes for given x- computes y-coodinates of P(x,y) point belonging EC if existing
+*/
+
+/*F*
+// Name: ippsGFpECMakePoint
+//
+// Purpose: Constructs the coordinates of a point on an elliptic curve based on the X-coordinate
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pX == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+// invalid pX->idCtx
+//
+// ippStsBadArgErr !GFP_IS_BASIC(GFP_PMA(ECP_GFP(pEC)))
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+// GFPE_ROOM(pX)!=GFP_FELEN()
+//
+// ippStsQuadraticNonResidueErr square of the Y-coordinate of
+// the pPoint is a quadratic non-residue modulo
+//
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pX Pointer to the X-coordinate of the point on the elliptic curve
+//
+// Note:
+// Is not a fact that computed point belongs to BP-related subgroup BP
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECMakePoint,(const IppsGFpElement* pX, IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR3_RET(pX, pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFP_IS_BASIC(GFP_PMA(ECP_GFP(pEC))), ippStsBadArgErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ return gfec_MakePoint(pPoint, GFPE_DATA(pX), pEC)? ippStsNoErr : ippStsQuadraticNonResidueErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecmulpoint.c b/ext/ipp/sources/ippcp/pcpgfpecmulpoint.c
new file mode 100644
index 0000000..9c8993e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecmulpoint.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECMulPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+/*F*
+// Name: ippsGFpECMulPoint
+//
+// Purpose: Multiplies a point on an elliptic curve by a scalar
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pQ == NULL
+// pR == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// pEC->subgroup == NULL
+// invalid pP->idCtx
+// invalid pQ->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+// ECP_POINT_FELEN(pR)!=GFP_FELEN()
+//
+// ippStsBadArgErr pN is negative
+// pN > MOD_MODULUS(ECP_MONT_R(pEC))
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the context of the given point on the elliptic curve
+// pN Pointer to the Big Number context storing the scalar value
+// pR Pointer to the context of the resulting elliptic curve point
+// pEC Pointer to the context of the elliptic curve
+// pScratchBuffer Pointer to the scratch buffer
+//
+// Note:
+// computes [N]*P, 0 < N < order
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECMulPoint,(const IppsGFpECPoint* pP,
+ const IppsBigNumState* pN,
+ IppsGFpECPoint* pR,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IPP_BAD_PTR4_RET(pP, pR, pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ IPP_BAD_PTR1_RET(pN);
+ pN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pN), ippStsContextMatchErr );
+ IPP_BADARG_RET( BN_NEGATIVE(pN), ippStsBadArgErr );
+
+ {
+ BNU_CHUNK_T* pScalar = BN_NUMBER(pN);
+ int scalarLen = BN_SIZE(pN);
+ IPP_BADARG_RET(0<cpCmp_BNU(pScalar, scalarLen, MOD_MODULUS(ECP_MONT_R(pEC)), MOD_LEN(ECP_MONT_R(pEC))), ippStsBadArgErr);
+
+ gfec_MulPoint(pR, pP, pScalar, scalarLen, pEC, pScratchBuffer);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecnegpoint.c b/ext/ipp/sources/ippcp/pcpgfpecnegpoint.c
new file mode 100644
index 0000000..0fe8dd4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecnegpoint.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECNegPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECNegPoint
+//
+// Purpose: Computes the inverse of a point
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pR == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pP->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+// ECP_POINT_FELEN(pR)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the context of the first elliptic curve point
+// pR Pointer to the context of the resulting elliptic curve point
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+
+IPPFUN(IppStatus, ippsGFpECNegPoint,(const IppsGFpECPoint* pP,
+ IppsGFpECPoint* pR,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR3_RET(pP, pR, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ gfec_NegPoint(pR, pP, pEC);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecpoint.c b/ext/ipp/sources/ippcp/pcpgfpecpoint.c
new file mode 100644
index 0000000..1444156
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecpoint.c
@@ -0,0 +1,137 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECPointGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECPointGetSize
+//
+// Purpose: Gets the size of the IppsGFpECPoint context
+//
+// Returns: Reason:
+// ippStsNullPtrErr pEC == NULL
+// pSize == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pEC Pointer to the context of the elliptic curve
+// pSize Pointer to the buffer size
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSize))
+{
+ IPP_BAD_PTR2_RET(pEC, pSize);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ {
+ int elemLen = GFP_FELEN(GFP_PMA(ECP_GFP(pEC)));
+ *pSize = sizeof(IppsGFpECPoint)
+ +elemLen*sizeof(BNU_CHUNK_T) /* X */
+ +elemLen*sizeof(BNU_CHUNK_T) /* Y */
+ +elemLen*sizeof(BNU_CHUNK_T);/* Z */
+ return ippStsNoErr;
+ }
+}
+
+/*F*
+// Name: ippsGFpECPointInit
+//
+// Purpose: Initializes the context of a point on an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pX, pY Pointers to the X and Y coordinates of a point on the elliptic curve
+// pPoint Pointer to the IppsGFpECPoint context being initialized
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECPointInit,(const IppsGFpElement* pX, const IppsGFpElement* pY,
+ IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ {
+ Ipp8u* ptr = (Ipp8u*)pPoint;
+ int elemLen = GFP_FELEN(GFP_PMA(ECP_GFP(pEC)));
+
+ ECP_POINT_ID(pPoint) = idCtxGFPPoint;
+ ECP_POINT_FLAGS(pPoint) = 0;
+ ECP_POINT_FELEN(pPoint) = elemLen;
+ ptr += sizeof(IppsGFpECPoint);
+ ECP_POINT_DATA(pPoint) = (BNU_CHUNK_T*)(ptr);
+
+ if(pX && pY)
+ return ippsGFpECSetPoint(pX, pY, pPoint, pEC);
+ else {
+ gfec_SetPointAtInfinity(pPoint);
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecpointstuff.c b/ext/ipp/sources/ippcp/pcpgfpecpointstuff.c
new file mode 100644
index 0000000..8963716
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecpointstuff.c
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal EC over GF(p^m) basic Definitions & Function Prototypes
+//
+// Context:
+// gfec_IsPointOnCurve()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "gsscramble.h"
+
+
+#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
+int gfec_IsPointOnCurve(const IppsGFpECPoint* pPoint, IppsGFpECState* pEC)
+{
+ /* point at infinity does not belong curve */
+ if( !IS_ECP_FINITE_POINT(pPoint) )
+ //return 1;
+ return 0;
+
+ /* test that 0 == R = (Y^2) - (X^3 + A*X*(Z^4) + B*(Z^6)) */
+ else {
+ int isOnCurve = 0;
+
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
+ mod_sub subF = GFP_METHOD(pGFE)->sub;
+
+ BNU_CHUNK_T* pX = ECP_POINT_X(pPoint);
+ BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
+ BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint);
+
+ BNU_CHUNK_T* pR = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
+
+ sqrF(pR, pY, pGFE); /* R = Y^2 */
+ sqrF(pT, pX, pGFE); /* T = X^3 */
+ mulF(pT, pX, pT, pGFE);
+ subF(pR, pR, pT, pGFE); /* R -= T */
+
+ if( IS_ECP_AFFINE_POINT(pPoint) ) {
+ mulF(pT, pX, ECP_A(pEC), pGFE); /* T = A*X */
+ subF(pR, pR, pT, pGFE); /* R -= T */
+ subF(pR, pR, ECP_B(pEC), pGFE); /* R -= B */
+ }
+ else {
+ BNU_CHUNK_T* pZ4 = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pZ6 = cpGFpGetPool(1, pGFE);
+
+ sqrF(pZ6, pZ, pGFE); /* Z^2 */
+ sqrF(pZ4, pZ6, pGFE); /* Z^4 */
+ mulF(pZ6, pZ6, pZ4, pGFE); /* Z^6 */
+
+ mulF(pZ4, pZ4, pX, pGFE); /* X*(Z^4) */
+ mulF(pZ4, pZ4, ECP_A(pEC), pGFE); /* A*X*(Z^4) */
+ mulF(pZ6, pZ6, ECP_B(pEC), pGFE); /* B*(Z^4) */
+
+ subF(pR, pR, pZ4, pGFE); /* R -= A*X*(Z^4) */
+ subF(pR, pR, pZ6, pGFE); /* R -= B*(Z^6) */
+
+ cpGFpReleasePool(2, pGFE);
+ }
+
+ isOnCurve = GFP_IS_ZERO(pR, GFP_FELEN(pGFE));
+ cpGFpReleasePool(2, pGFE);
+ return isOnCurve;
+ }
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpgfpecprivatekey.c b/ext/ipp/sources/ippcp/pcpgfpecprivatekey.c
new file mode 100644
index 0000000..add30a9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecprivatekey.c
@@ -0,0 +1,121 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECPrivateKey()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+/*F*
+// Name: ippsGFpECPrivateKey
+//
+// Purpose: Generate random private key
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivate
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pPrivate->idCtx
+//
+// ippStsSizeErr BN_ROOM(pPrivate)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivate pointer to the resultant private key
+// pEC pointer to the EC context
+// rndFunc Specified Random Generator
+// pRndParam Pointer to the Random Generator context
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECPrivateKey, (IppsBigNumState* pPrivate, IppsGFpECState* pEC,
+ IppBitSupplier rndFunc, void* pRndParam))
+{
+ IPP_BAD_PTR2_RET(pEC, rndFunc);
+
+ /* use aligned EC context */
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ /* test private key */
+ IPP_BAD_PTR1_RET(pPrivate);
+ pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pPrivate)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsSizeErr);
+
+ {
+ /* generate random private key X: 0 < X < R */
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
+ int orderBitLen = ECP_ORDBITSIZE(pEC);
+ int orderLen = BITS_BNU_CHUNK(orderBitLen);
+
+ BNU_CHUNK_T* pX = BN_NUMBER(pPrivate);
+ int nsX = BITS_BNU_CHUNK(orderBitLen);
+ BNU_CHUNK_T xMask = MASK_BNU_CHUNK(orderBitLen);
+
+ IppStatus sts;
+ do {
+ sts = rndFunc((Ipp32u*)pX, orderBitLen, pRndParam);
+ if(ippStsNoErr!=sts)
+ break;
+ pX[nsX-1] &= xMask;
+ } while( (1 == cpEqu_BNU_CHUNK(pX, nsX, 0)) ||
+ (0 <= cpCmp_BNU(pX, nsX, pOrder, orderLen)) );
+
+ /* set up private */
+ if(ippStsNoErr==sts) {
+ BN_SIGN(pPrivate) = ippBigNumPOS;
+ FIX_BNU(pX, nsX);
+ BN_SIZE(pPrivate) = nsX;
+ }
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecpublickey.c b/ext/ipp/sources/ippcp/pcpgfpecpublickey.c
new file mode 100644
index 0000000..d218371
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecpublickey.c
@@ -0,0 +1,118 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECPublicKey()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+
+
+
+/*F*
+// Name: ippsGFpECPublicKey
+//
+// Purpose: Compute Public Key
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pPrivate
+// NULL == pPublic
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pPrivate->idCtx
+// illegal pPublic->idCtx
+//
+// ippStsIvalidPrivateKey !(0 < pPrivate < order)
+//
+// ippStsRangeErr ECP_POINT_FELEN(pPublic)<GFP_FELEN()
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pPrivate pointer to the private key
+// pPublic pointer to the resultant public key
+// pEC pointer to the EC context
+// pScratchBuffer pointer to buffer (1 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECPublicKey, (const IppsBigNumState* pPrivate, IppsGFpECPoint* pPublic,
+ IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+{
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ /* test private keys */
+ IPP_BAD_PTR1_RET(pPrivate);
+ pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
+
+ /* test public key */
+ IPP_BAD_PTR1_RET(pPublic);
+ IPP_BADARG_RET(!ECP_POINT_TEST_ID(pPublic), ippStsContextMatchErr);
+ IPP_BADARG_RET(ECP_POINT_FELEN(pPublic)<GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsRangeErr);
+
+ {
+ BNU_CHUNK_T* pS= BN_NUMBER(pPrivate);
+ int nsS= BN_SIZE(pPrivate);
+
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
+ int orderLen = BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC));
+
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pS, nsS, 0)
+ || 0<=cpCmp_BNU(pS, nsS, pOrder, orderLen), ippStsIvalidPrivateKey);
+
+ /* calculates public key */
+ gfec_MulBasePoint(pPublic, pS, nsS, pEC, pScratchBuffer);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecset.c b/ext/ipp/sources/ippcp/pcpgfpecset.c
new file mode 100644
index 0000000..d2cb57c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecset.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECSet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECSet
+//
+// Purpose: Sets up the parameters of an elliptic curve over a finite field
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pA
+// NULL == pB
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pA->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pA)!=GFP_FELEN(pGFE)
+// GFPE_ROOM(pB)!=GFP_FELEN(pGFE)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the coefficient A of the equation defining the elliptic curve
+// pB Pointer to the coefficient B of the equation defining the elliptic curve
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSet,(const IppsGFpElement* pA,
+ const IppsGFpElement* pB,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ IPP_BAD_PTR2_RET(pA, pB);
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(ECP_GFP(pEC));
+ int elemLen = GFP_FELEN(pGFE);
+
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( GFPE_ROOM(pB)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ /* copy A */
+ cpGFpElementPadd(ECP_A(pEC), elemLen, 0);
+ cpGFpElementCopy(ECP_A(pEC), GFPE_DATA(pA), elemLen);
+ /* and set up A-specific (a==0 or a==-3) if is */
+ if(GFP_IS_ZERO(ECP_A(pEC), elemLen))
+ ECP_SPECIFIC(pEC) = ECP_EPID2;
+
+ cpGFpElementSetChunk(ECP_B(pEC), elemLen, 3);
+ GFP_METHOD(pGFE)->encode(ECP_B(pEC), ECP_B(pEC), pGFE);
+ GFP_METHOD(pGFE)->add(ECP_B(pEC), ECP_A(pEC), ECP_B(pEC), pGFE);
+ if(GFP_IS_ZERO(ECP_B(pEC), elemLen))
+ ECP_SPECIFIC(pEC) = ECP_STD;
+
+ /* copy B */
+ cpGFpElementPadd(ECP_B(pEC), elemLen, 0);
+ cpGFpElementCopy(ECP_B(pEC), GFPE_DATA(pB), elemLen);
+ /* and set type of affine infinity representation:
+ // (0,1) if B==0
+ // (0,0) if B!=0 */
+ ECP_INFINITY(pEC) = GFP_IS_ZERO(ECP_B(pEC), elemLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpoint.c b/ext/ipp/sources/ippcp/pcpgfpecsetpoint.c
new file mode 100644
index 0000000..b060b6a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpoint.c
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECSetPoint
+//
+// Purpose: Sets a point on an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pX == NULL
+// pY == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+// invalid pX->idCtx
+// invalid pY->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pX)!=GFP_FELEN()
+// ECP_POINT_FELEN(pY)!=GFP_FELEN()
+// ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pX, pY Pointers to the X and Y coordinates of a point on the elliptic curve
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetPoint,(const IppsGFpElement* pX, const IppsGFpElement* pY,
+ IppsGFpECPoint* pPoint,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BAD_PTR2_RET(pX, pY);
+ IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ if(gfec_SetPoint(ECP_POINT_DATA(pPoint), GFPE_DATA(pX), GFPE_DATA(pY), pEC))
+ ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
+ else
+ ECP_POINT_FLAGS(pPoint) = 0;
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointatinf.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointatinf.c
new file mode 100644
index 0000000..dcd663b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointatinf.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointAtInfinity()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECSetPointAtInfinity
+//
+// Purpose: Sets a point on an elliptic curve as a point at infinity
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN()!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetPointAtInfinity,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ gfec_SetPointAtInfinity(pPoint);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointhash.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointhash.c
new file mode 100644
index 0000000..d7e2595
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointhash.c
@@ -0,0 +1,177 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointHash()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECSetPointHash
+//
+// Purpose: Constructs a point on an elliptic curve based on the hash of the input message
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pScratchBuffer == NULL
+// (msgLen && !pMsg)
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+//
+// ippStsBadArgErr !GFP_IS_BASIC(pGFE)
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+//
+// ippStsQuadraticNonResidueErr square of the Y-coordinate of
+// the pPoint is a quadratic non-residue modulo
+//
+// ippStsLengthErr msgLen<0
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// hdr Header of the input message
+// pMsg Pointer to the input message
+// msgLen Length of the input message
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// hashID ID of the hash algorithm used
+// pScratchBuffer Pointer to the scratch buffer
+//
+// Note:
+// Is not a fact that computed point belongs to BP-related subgroup BP
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetPointHash,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppsGFpECPoint* pPoint,
+ IppsGFpECState* pEC, IppHashAlgId hashID,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* get algorithm id */
+ hashID = cpValidHashAlg(hashID);
+ IPP_BADARG_RET(ippHashAlg_Unknown==hashID, ippStsNotSupportedModeErr);
+
+ /* test message length */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ {
+ int elemLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
+
+ Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
+ int hashLen = cpHashAlgAttr[hashID].hashSize;
+ BNU_CHUNK_T hashVal[BITS_BNU_CHUNK(IPP_SHA512_DIGEST_BITSIZE)+1];
+ int hashValLen;
+
+ IppsHashState hashCtx;
+ ippsHashInit(&hashCtx, hashID);
+
+ {
+ BNU_CHUNK_T* pPoolElm = cpGFpGetPool(1, pGFE);
+
+ /* convert hdr => hdrStr */
+ BNU_CHUNK_T locHdr = (BNU_CHUNK_T)hdr;
+ Ipp8u hdrOctStr[sizeof(hdr/*locHdr*/)];
+ cpToOctStr_BNU(hdrOctStr, sizeof(hdrOctStr), &locHdr, 1);
+
+ /* compute md = hash(hrd||msg) */
+ ippsHashUpdate(hdrOctStr, sizeof(hdrOctStr), &hashCtx);
+ ippsHashUpdate(pMsg, msgLen, &hashCtx);
+ ippsHashFinal(md, &hashCtx);
+
+ /* convert hash into the integer */
+ hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
+ hashValLen = cpMod_BNU(hashVal, hashValLen, pModulus, elemLen);
+ cpGFpSet(pPoolElm, hashVal, hashValLen, pGFE);
+
+ if( gfec_MakePoint(pPoint, pPoolElm, pEC)) {
+ /* set y-coordinate of the point (positive or negative) */
+ BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
+ if(pY[0] & 1)
+ cpGFpNeg(pY, pY, pGFE);
+
+ /* R = [cofactor]R */
+ if(ECP_SUBGROUP(pEC)) {
+ BNU_CHUNK_T* pCofactor = ECP_COFACTOR(pEC);
+ int cofactorLen = GFP_FELEN(pGFE);
+ if(!GFP_IS_ONE(pCofactor, cofactorLen))
+ gfec_MulPoint(pPoint, pPoint, pCofactor, cofactorLen, /*0,*/ pEC, pScratchBuffer);
+ }
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsNoErr;
+ }
+ }
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsQuadraticNonResidueErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointhash_rmf.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointhash_rmf.c
new file mode 100644
index 0000000..beebf8e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointhash_rmf.c
@@ -0,0 +1,173 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointHash_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+
+/*F*
+// Name: ippsGFpECSetPointHash_rmf
+//
+// Purpose: Constructs a point on an elliptic curve based on the hash of the input message
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pScratchBuffer == NULL
+// (msgLen && !pMsg)
+// pMethod == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+//
+// ippStsBadArgErr !GFP_IS_BASIC(pGFE)
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+//
+// ippStsQuadraticNonResidueErr square of the Y-coordinate of
+// the pPoint is a quadratic non-residue modulo
+//
+// ippStsLengthErr msgLen<0
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// hdr Header of the input message
+// pMsg Pointer to the input message
+// msgLen Length of the input message
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pMethod Pointer to the hash method
+// pScratchBuffer Pointer to the scratch buffer
+//
+// Note:
+// Is not a fact that computed point belongs to BP-related subgroup BP
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSetPointHash_rmf,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppsGFpECPoint* pPoint,
+ IppsGFpECState* pEC, const IppsHashMethod* pMethod,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* test method pointer */
+ IPP_BAD_PTR1_RET(pMethod);
+
+ /* test message length */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ {
+ int elemLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
+
+ Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
+ int hashLen = pMethod->hashLen;
+ BNU_CHUNK_T hashVal[BITS_BNU_CHUNK(IPP_SHA512_DIGEST_BITSIZE)+1];
+ int hashValLen;
+
+ IppsHashState_rmf hashCtx;
+ ippsHashInit_rmf(&hashCtx, pMethod);
+
+ {
+ BNU_CHUNK_T* pPoolElm = cpGFpGetPool(1, pGFE);
+
+ /* convert hdr => hdrStr */
+ BNU_CHUNK_T locHdr = (BNU_CHUNK_T)hdr;
+ Ipp8u hdrOctStr[sizeof(hdr/*locHdr*/)];
+ cpToOctStr_BNU(hdrOctStr, sizeof(hdrOctStr), &locHdr, 1);
+
+ /* compute md = hash(hrd||msg) */
+ ippsHashUpdate_rmf(hdrOctStr, sizeof(hdrOctStr), &hashCtx);
+ ippsHashUpdate_rmf(pMsg, msgLen, &hashCtx);
+ ippsHashFinal_rmf(md, &hashCtx);
+
+ /* convert hash into the integer */
+ hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
+ hashValLen = cpMod_BNU(hashVal, hashValLen, pModulus, elemLen);
+ cpGFpSet(pPoolElm, hashVal, hashValLen, pGFE);
+
+ if( gfec_MakePoint(pPoint, pPoolElm, pEC)) {
+ /* set y-coordinate of the point (positive or negative) */
+ BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
+ if(pY[0] & 1)
+ cpGFpNeg(pY, pY, pGFE);
+
+ /* update point if cofactor>1 */
+ if(ECP_SUBGROUP(pEC))
+ gfec_MulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGFE), /*0,*/ pEC, pScratchBuffer);
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsNoErr;
+ }
+ }
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsQuadraticNonResidueErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointoctstring.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointoctstring.c
new file mode 100644
index 0000000..ccd0e16
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointoctstring.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointOctString()
+//
+*/
+
+#include "pcpgfpecessm2.h"
+#include "pcpgfpecstuff.h"
+
+/*F*
+// Name: ippsGFpECSetPointOctString
+//
+// Purpose: Converts x||y octstring into a point on EC
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL / pEC == NULL / pStr == NULL
+// ippStsContextMatchErr pEC, pPoint invalid context
+// ippStsNotSupportedModeErr pGFE->extdegree > 1
+// ippStsSizeErr strLen is not equal to double GFp element
+// ippStsOutOfRangeErr X or Y from the string exceeds the EC's field modulus or the point does not belong to the EC
+// ippStsNoErr no errors
+//
+// Parameters:
+// pStr pointer to the string to read from
+// strLen length of the string
+// pPoint pointer to output point
+// pEC EC ctx
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSetPointOctString, (const Ipp8u* pStr,
+ int strLen, IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) {
+ IPP_BAD_PTR3_RET(pPoint, pEC, pStr);
+ IPP_BADARG_RET(pEC->idCtx != idCtxGFPEC, ippStsContextMatchErr);
+ IPP_BADARG_RET(!pEC->subgroup, ippStsContextMatchErr);
+ IPP_BADARG_RET(1 < pEC->pGF->pGFE->extdegree, ippStsNotSupportedModeErr);
+
+ {
+ gsModEngine* pGFE = pEC->pGF->pGFE;
+ int elemLen = BITS2WORD8_SIZE(pGFE->modBitLen);
+ IPP_BADARG_RET(strLen != elemLen * 2, ippStsSizeErr);
+
+ {
+ IppStatus ret;
+ IppsGFpElement ptX, ptY;
+ cpGFpElementConstruct(&ptX, cpGFpGetPool(1, pGFE), pGFE->modLen);
+ cpGFpElementConstruct(&ptY, cpGFpGetPool(1, pGFE), pGFE->modLen);
+
+ ret = ippsGFpSetElementOctString(pStr, elemLen, &ptX, pEC->pGF);
+ if (ippStsNoErr == ret) {
+ pStr += elemLen;
+ ret = ippsGFpSetElementOctString(pStr, elemLen, &ptY, pEC->pGF);
+ }
+ if (ippStsNoErr == ret) {
+ ret = ippsGFpECSetPoint(&ptX, &ptY, pPoint, pEC);
+ }
+
+ cpGFpReleasePool(2, pGFE); /* release ptX and ptY from the pool */
+
+ return ret;
+ }
+ }
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointrand.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointrand.c
new file mode 100644
index 0000000..e926fdb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointrand.c
@@ -0,0 +1,159 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointRandom()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECSetPointRandom
+//
+// Purpose: Sets the coordinates of a point on an elliptic curve to random values
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pScratchBuffer == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// NULL == pEC->subgroup
+// invalid pPoint->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// rndFunc Pesudorandom number generator
+// pRndParam Pointer to the pseudorandom number generator context
+// pScratchBuffer Pointer to the scratch buffer
+//
+// Note:
+// Is not a fact that computed point belongs to BP-related subgroup BP
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetPointRandom,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC,
+ IppBitSupplier rndFunc, void* pRndParam,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ IPP_BAD_PTR2_RET(rndFunc, pRndParam);
+
+ {
+ int internal_err;
+
+ if( GFP_IS_BASIC(pGFE) ) {
+ BNU_CHUNK_T* pElm = cpGFpGetPool(1, pGFE);
+
+ do { /* get random X */
+ internal_err = NULL==cpGFpRand(pElm, pGFE, rndFunc, pRndParam);
+ } while( !internal_err && !gfec_MakePoint(pPoint, pElm, pEC) );
+
+ cpGFpReleasePool(1, pGFE);
+
+ /* R = [cofactor]R */
+ if(!internal_err && ECP_SUBGROUP(pEC)) {
+ BNU_CHUNK_T* pCofactor = ECP_COFACTOR(pEC);
+ int cofactorLen = GFP_FELEN(pGFE);
+ if(!GFP_IS_ONE(pCofactor, cofactorLen))
+ gfec_MulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGFE), /*0,*/ pEC, pScratchBuffer);
+ }
+ }
+
+ else {
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+ {
+ /* number of bits being generated */
+ int generatedBits = ECP_ORDBITSIZE(pEC) + GFP_RAND_ADD_BITS;
+ int generatedLen = BITS_BNU_CHUNK(generatedBits);
+
+ /* allocate random exponent */
+ int poolElements = (generatedLen + GFP_PELEN(pGFE) -1) / GFP_PELEN(pGFE);
+ BNU_CHUNK_T* pExp = cpGFpGetPool(poolElements, pGFE);
+
+ /* setup copy of the base point */
+ IppsGFpECPoint G;
+ cpEcGFpInitPoint(&G, ECP_G(pEC),ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
+
+ /* get random bits */
+ internal_err = ippStsNoErr != rndFunc((Ipp32u*)pExp, generatedBits, pRndParam);
+
+ if(!internal_err) {
+ /* reduce with respect to order value */
+ int nsE = cpMod_BNU(pExp, generatedLen, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)));
+ /* compute random point */
+ gfec_MulPoint(pPoint, &G, pExp, nsE, pEC, pScratchBuffer);
+ }
+
+ cpGFpReleasePool(poolElements, pGFE);
+ }
+ }
+
+ return internal_err? ippStsErr : ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetpointreg.c b/ext/ipp/sources/ippcp/pcpgfpecsetpointreg.c
new file mode 100644
index 0000000..13f49db
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetpointreg.c
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECSetPointRegular()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECSetPointRegular
+//
+// Purpose: Sets a point with Big Number coordinates
+//
+// Returns: Reason:
+// ippStsNullPtrErr pPoint == NULL
+// pEC == NULL
+// pX == NULL
+// pY == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pPoint->idCtx
+// invalid pX->idCtx
+// invalid pY->idCtx
+//
+// ippStsOutOfRangeErr GFP_FELEN() < pX <= 0
+// GFP_FELEN() < pY <= 0
+// ECP_POINT_FELEN(pPoint)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pX, pY Pointers to the X and Y coordinates of a point on the elliptic curve
+// pPoint Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetPointRegular,(const IppsBigNumState* pX, const IppsBigNumState* pY,
+ IppsGFpECPoint* pPoint,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR2_RET(pPoint, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
+
+ IPP_BAD_PTR2_RET(pX, pY);
+ pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, BN_ALIGNMENT) );
+ pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, BN_ALIGNMENT) );
+ IPP_BADARG_RET( !BN_VALID_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( !BN_VALID_ID(pY), ippStsContextMatchErr );
+ IPP_BADARG_RET( !BN_POSITIVE(pX), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( !BN_POSITIVE(pY), ippStsOutOfRangeErr);
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr )
+
+ IPP_BADARG_RET( BN_SIZE(pX) > elemLen, ippStsOutOfRangeErr);
+ IPP_BADARG_RET( BN_SIZE(pY) > elemLen, ippStsOutOfRangeErr);
+ IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=elemLen, ippStsOutOfRangeErr);
+
+ {
+ BNU_CHUNK_T* pointX = ECP_POINT_X(pPoint);
+ BNU_CHUNK_T* pointY = ECP_POINT_Y(pPoint);
+ BNU_CHUNK_T* pointZ = ECP_POINT_Z(pPoint);
+
+ cpGFpElementCopyPadd(pointX, elemLen, BN_NUMBER(pX), BN_SIZE(pX));
+ cpGFpElementCopyPadd(pointY, elemLen, BN_NUMBER(pY), BN_SIZE(pY));
+ cpGFpElementCopy(pointZ, MOD_MNT_R(pGFE), elemLen);
+
+ if( cpGFpSet(pointX, pointX, elemLen, pGFE) && cpGFpSet(pointY, pointY, elemLen, pGFE) )
+ ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
+ else
+ gfec_SetPointAtInfinity(pPoint);
+
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsetsubgroup.c b/ext/ipp/sources/ippcp/pcpgfpecsetsubgroup.c
new file mode 100644
index 0000000..b841102
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsetsubgroup.c
@@ -0,0 +1,146 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECSetSubgroup()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECSetSubgroup
+//
+// Purpose: Sets up the parameters defining an elliptic curve points subgroup.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pX
+// NULL == pY
+// NULL == pOrder
+// NULL == pCofactor
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pX->idCtx
+// invalid pY->idCtx
+// invalid pOrder->idCtx
+// invalid pCofactor->idCtx
+//
+// ippStsBadArgErr pOrder <= 0
+// pCofactor <= 0
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pX)!=GFP_FELEN(pGFE)
+// GFPE_ROOM(pY)!=GFP_FELEN(pGFE)
+//
+// ippStsRangeErr orderBitSize>maxOrderBits
+// cofactorBitSize>elemLen*BITSIZE(BNU_CHUNK_T)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pX, pY Pointers to the X and Y coordinates of the base point of the elliptic curve
+// pOrder Pointer to the big number context storing the order of the base point.
+// pCofactor Pointer to the big number context storing the cofactor.
+// pEC Pointer to the context of the elliptic curve.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECSetSubgroup,(const IppsGFpElement* pX, const IppsGFpElement* pY,
+ const IppsBigNumState* pOrder,
+ const IppsBigNumState* pCofactor,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR1_RET(pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ IPP_BAD_PTR2_RET(pX, pY);
+ IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
+
+ IPP_BAD_PTR2_RET(pOrder, pCofactor);
+ pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_SIGN(pOrder)!= IppsBigNumPOS, ippStsBadArgErr);
+
+ pCofactor = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCofactor, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pCofactor), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_SIGN(pCofactor)!= IppsBigNumPOS, ippStsBadArgErr);
+
+ {
+ gsModEngine* pGFE = GFP_PMA(ECP_GFP(pEC));
+ int elemLen = GFP_FELEN(pGFE);
+
+ IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ gfec_SetPoint(ECP_G(pEC), GFPE_DATA(pX), GFPE_DATA(pY), pEC);
+
+ {
+ int maxOrderBits = 1+ cpGFpBasicDegreeExtension(pGFE) * GFP_FEBITLEN(cpGFpBasic(pGFE));
+ BNU_CHUNK_T* pOrderData = BN_NUMBER(pOrder);
+ int orderLen= BN_SIZE(pOrder);
+ int orderBitSize = BITSIZE_BNU(pOrderData, orderLen);
+ IPP_BADARG_RET(orderBitSize>maxOrderBits, ippStsRangeErr)
+
+ /* set actual size of order and re-init engine */
+ ECP_ORDBITSIZE(pEC) = orderBitSize;
+ gsModEngineInit(ECP_MONT_R(pEC),(Ipp32u*)pOrderData, orderBitSize, MONT_DEFAULT_POOL_LENGTH, gsModArithMont());
+ }
+
+ {
+ BNU_CHUNK_T* pCofactorData = BN_NUMBER(pCofactor);
+ int cofactorLen= BN_SIZE(pCofactor);
+ int cofactorBitSize = BITSIZE_BNU(pCofactorData, cofactorLen);
+ IPP_BADARG_RET(cofactorBitSize>elemLen*BITSIZE(BNU_CHUNK_T), ippStsRangeErr)
+ COPY_BNU(ECP_COFACTOR(pEC), pCofactorData, cofactorLen);
+ }
+
+ ECP_SUBGROUP(pEC) = 1;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsigndsa.c b/ext/ipp/sources/ippcp/pcpgfpecsigndsa.c
new file mode 100644
index 0000000..e44db19
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsigndsa.c
@@ -0,0 +1,250 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECSignDSA()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECSignDSA
+//
+// Purpose: DSA Signature Generation.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPrivate
+// NULL == pEphPrivate
+// NULL == pSignR
+// NULL == pSignS
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pMsgDigest->idCtx
+// illegal pRegPrivate->idCtx
+// illegal pEphPrivate->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsIvalidPrivateKey 0 >= RegPrivate
+// RegPrivate >= order
+//
+// 0 >= EphPrivate
+// EphPrivate >= order
+//
+// ippStsMessageErr MsgDigest >= order
+// MsgDigest < 0
+//
+// ippStsRangeErr not enough room for:
+// signR
+// signS
+//
+// ippStsEphemeralKeyErr (0==signR) || (0==signS)
+//
+// ippStsNotSupportedModeErr pGFE->extdegree > 1
+//
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pRegPrivate pointer to the regular private key
+// pEphPrivate pointer to the ephemeral private key
+// pSignR,pSignS pointer to the signature
+// pEC pointer to the EC context
+// pScratchBuffer pointer to buffer (1 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSignDSA,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pRegPrivate,
+ const IppsBigNumState* pEphPrivate,
+ IppsBigNumState* pSignR, IppsBigNumState* pSignS,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pMontP;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pMontP = GFP_PMA(pGF);
+ IPP_BADARG_RET(1<GFP_EXTDEGREE(pMontP), ippStsNotSupportedModeErr);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignR, pSignS);
+ pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, BN_ALIGNMENT) );
+ pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pSignR)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+ IPP_BADARG_RET((BN_ROOM(pSignS)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ /* test private keys */
+ IPP_BAD_PTR2_RET(pRegPrivate, pEphPrivate);
+
+ pRegPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRegPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pRegPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pRegPrivate), ippStsIvalidPrivateKey);
+
+ pEphPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pEphPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pEphPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pEphPrivate), ippStsEphemeralKeyErr);
+
+ {
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int ordLen = MOD_LEN(pMontR);
+
+ BNU_CHUNK_T* dataC = BN_NUMBER(pSignR);
+ BNU_CHUNK_T* dataD = BN_NUMBER(pSignS);
+ BNU_CHUNK_T* buffF = BN_BUFFER(pSignR);
+ BNU_CHUNK_T* buffT = BN_BUFFER(pSignS);
+
+ BNU_CHUNK_T* pPriData = BN_NUMBER(pRegPrivate);
+ int priLen = BN_SIZE(pRegPrivate);
+
+ BNU_CHUNK_T* pEphData = BN_NUMBER(pEphPrivate);
+ int ephLen = BN_SIZE(pEphPrivate);
+
+ BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
+ int msgLen = BN_SIZE(pMsgDigest);
+
+ /* test value of private keys: 0 < regPrivate < order, 0 < ephPrivate < order */
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pPriData, priLen, 0) ||
+ 0<=cpCmp_BNU(pPriData, priLen, pOrder, ordLen), ippStsIvalidPrivateKey);
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pEphData, ephLen, 0) ||
+ 0<=cpCmp_BNU(pEphData, ephLen, pOrder, ordLen), ippStsEphemeralKeyErr);
+
+ /* make sure msg <order */
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, ordLen), ippStsMessageErr);
+
+ {
+ int elmLen = GFP_FELEN(pMontP);
+ int ns;
+
+ /* compute ephemeral public key */
+ IppsGFpECPoint ephPublic;
+ cpEcGFpInitPoint(&ephPublic, cpEcGFpGetPool(1, pEC), 0, pEC);
+ gfec_MulBasePoint(&ephPublic,
+ BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate),
+ pEC, pScratchBuffer);
+
+ /*
+ // signR = int(ephPublic.x) (mod order)
+ */
+ {
+ BNU_CHUNK_T* buffer = gsModPoolAlloc(pMontP, 1);
+ gfec_GetPoint(buffer, NULL, &ephPublic, pEC);
+ GFP_METHOD(pMontP)->decode(buffer, buffer, pMontP);
+ ns = cpMod_BNU(buffer, elmLen, pOrder, ordLen);
+ cpGFpElementCopyPadd(dataC, ordLen, buffer, ns);
+ gsModPoolFree(pMontP, 1);
+ }
+ cpEcGFpReleasePool(1, pEC);
+
+ if(!GFP_IS_ZERO(dataC, ordLen)) {
+ /*
+ // signS = (1/ephPrivate)*(pMsgDigest + private*signR) (mod order)
+ */
+
+ /* reduce message: msg = msg mod ordfer */
+ BNU_CHUNK_T* buffMsg= BN_BUFFER(pMsgDigest);
+ COPY_BNU(buffMsg, pMsgData, msgLen);
+ ns = cpMod_BNU(buffMsg, msgLen, pOrder, ordLen);
+ /* copy and expand message is being signed */
+ ZEXPAND_COPY_BNU(buffF, ordLen, buffMsg, ns);
+
+ /* private representation in Montgomery domain */
+ ZEXPAND_COPY_BNU(dataD, ordLen, pPriData, priLen);
+ GFP_METHOD(pMontR)->encode(dataD, dataD, pMontR);
+
+ /* (private*signX) in regular domain */
+ GFP_METHOD(pMontR)->mul(dataD, dataD, dataC, pMontR);
+
+ /* pMsgDigest + private*signX */
+ cpModAdd_BNU(dataD, dataD, buffF, pOrder, ordLen, buffT);
+
+ if(!GFP_IS_ZERO(dataD, ordLen)) {
+ /* (1/ephPrivate) in Montgomery domain */
+ ZEXPAND_COPY_BNU(buffT, ordLen, pEphData, ephLen);
+ gs_mont_inv(buffT, buffT, pMontR, alm_mont_inv_ct);
+
+ /* (1/ephPrivate)*(pMsgDigest + private*signS) */
+ GFP_METHOD(pMontR)->mul(dataD, dataD, buffT, pMontR);
+
+ /* signR */
+ ns = ordLen;
+ FIX_BNU(dataC, ns);
+ BN_SIGN(pSignR) = ippBigNumPOS;
+ BN_SIZE(pSignR) = ns;
+ /* signS */
+ ns = ordLen;
+ FIX_BNU(dataD, ns);
+ BN_SIGN(pSignS) = ippBigNumPOS;
+ BN_SIZE(pSignS) = ns;
+
+ return ippStsNoErr;
+ }
+ }
+
+ return ippStsEphemeralKeyErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecsignnr.c b/ext/ipp/sources/ippcp/pcpgfpecsignnr.c
new file mode 100644
index 0000000..e53f945
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecsignnr.c
@@ -0,0 +1,229 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECSignNR()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECSignNR
+//
+// Purpose: NR Signature Generation.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPrivate
+// NULL == pEphPrivate
+// NULL == pSignR
+// NULL == pSignS
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pMsgDigest->idCtx
+// illegal pRegPrivate->idCtx
+// illegal pEphPrivate->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsIvalidPrivateKey 0 >= RegPrivate
+// RegPrivate >= order
+//
+// 0 >= EphPrivate
+// EphPrivate >= order
+//
+// ippStsMessageErr pMsgDigest < 0
+// pMsgDigest >= order
+//
+// ippStsRangeErr not enough room for:
+// signC
+// signD
+//
+// ippStsEphemeralKeyErr (0==signR) || (0==signS)
+//
+// ippStsNotSupportedModeErr 1<GFP_EXTDEGREE(pGFE)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to be signed
+// pRegPrivate pointer to the regular private key
+// pEphPrivate pointer to the ephemeral private key
+// pSignR,pSignS pointer to the signature
+// pEC pointer to the EC context
+// pScratchBuffer pointer to buffer (1 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECSignNR,(const IppsBigNumState* pMsgDigest,
+ const IppsBigNumState* pRegPrivate,
+ const IppsBigNumState* pEphPrivate,
+ IppsBigNumState* pSignR, IppsBigNumState* pSignS,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pMontP;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pMontP = GFP_PMA(pGF);
+ IPP_BADARG_RET(1<GFP_EXTDEGREE(pMontP), ippStsNotSupportedModeErr);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignR, pSignS);
+ pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, BN_ALIGNMENT) );
+ pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
+ IPP_BADARG_RET((BN_ROOM(pSignR)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+ IPP_BADARG_RET((BN_ROOM(pSignS)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
+
+ /* test private keys */
+ IPP_BAD_PTR2_RET(pRegPrivate, pEphPrivate);
+
+ pRegPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRegPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pRegPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pRegPrivate), ippStsIvalidPrivateKey);
+
+ pEphPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pEphPrivate, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pEphPrivate), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pEphPrivate), ippStsEphemeralKeyErr);
+
+ {
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int ordLen = MOD_LEN(pMontR);
+
+ BNU_CHUNK_T* dataC = BN_NUMBER(pSignR);
+ BNU_CHUNK_T* dataD = BN_NUMBER(pSignS);
+ BNU_CHUNK_T* buffF = BN_BUFFER(pSignR);
+ BNU_CHUNK_T* buffT = BN_BUFFER(pSignS);
+
+ BNU_CHUNK_T* pPriData = BN_NUMBER(pRegPrivate);
+ int priLen = BN_SIZE(pRegPrivate);
+
+ BNU_CHUNK_T* pEphData = BN_NUMBER(pEphPrivate);
+ int ephLen = BN_SIZE(pEphPrivate);
+
+ BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
+ int msgLen = BN_SIZE(pMsgDigest);
+
+ /* test value of private keys: 0 < regPrivate<order, 0 < ephPrivate < order */
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pPriData, priLen, 0) ||
+ 0<=cpCmp_BNU(pPriData, priLen, pOrder, ordLen), ippStsIvalidPrivateKey);
+ IPP_BADARG_RET(cpEqu_BNU_CHUNK(pEphData, ephLen, 0) ||
+ 0<=cpCmp_BNU(pEphData, ephLen, pOrder, ordLen), ippStsEphemeralKeyErr);
+
+ /* test mesage: msg < order */
+ IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, ordLen), ippStsMessageErr);
+
+ {
+ int elmLen = GFP_FELEN(pMontP);
+ int ns;
+
+ /* compute ephemeral public key */
+ IppsGFpECPoint ephPublic;
+ cpEcGFpInitPoint(&ephPublic, cpEcGFpGetPool(1, pEC), 0, pEC);
+ gfec_MulBasePoint(&ephPublic,
+ BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate),
+ pEC, pScratchBuffer);
+
+ /* x = (ephPublic.x) mod order */
+ {
+ BNU_CHUNK_T* buffer = gsModPoolAlloc(pMontP, 1);
+ gfec_GetPoint(buffer, NULL, &ephPublic, pEC);
+ GFP_METHOD(pMontP)->decode(buffer, buffer, pMontP);
+ ns = cpMod_BNU(buffer, elmLen, pOrder, ordLen);
+ cpGFpElementCopyPadd(dataC, ordLen, buffer, ns);
+ gsModPoolFree(pMontP, 1);
+ }
+ cpEcGFpReleasePool(1, pEC);
+
+ /* C = (ephPublic.x + msg) mod order */
+ ZEXPAND_COPY_BNU(buffF, ordLen, pMsgData, msgLen);
+ cpModAdd_BNU(dataC, dataC, buffF, pOrder, ordLen, dataD);
+
+ if(!GFP_IS_ZERO(dataC, ordLen)) {
+
+ /* signS = (eph_private - private*signR) (mod order) */
+ ZEXPAND_COPY_BNU(dataD, ordLen, pPriData, priLen);
+ GFP_METHOD(pMontR)->encode(dataD, dataD, pMontR);
+ GFP_METHOD(pMontR)->mul(dataD, dataD, dataC, pMontR);
+ ZEXPAND_COPY_BNU(buffF, ordLen, pEphData, ephLen);
+ cpModSub_BNU(dataD, buffF, dataD, pOrder, ordLen, buffT);
+
+ /* signR */
+ ns = ordLen;
+ FIX_BNU(dataC, ns);
+ BN_SIGN(pSignR) = ippBigNumPOS;
+ BN_SIZE(pSignR) = ns;
+ /* signS */
+ ns = ordLen;
+ FIX_BNU(dataD, ns);
+ BN_SIGN(pSignS) = ippBigNumPOS;
+ BN_SIZE(pSignS) = ns;
+
+ return ippStsNoErr;
+ }
+
+ return ippStsEphemeralKeyErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecstuff.h b/ext/ipp/sources/ippcp/pcpgfpecstuff.h
index b237201..2f0cd34 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpecstuff.h
+++ b/ext/ipp/sources/ippcp/pcpgfpecstuff.h
@@ -1,23 +1,47 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
// Purpose:
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// Internal EC over GF(p^m) basic Definitions & Function Prototypes
//
//
@@ -28,6 +52,7 @@
#include "pcpgfpstuff.h"
#include "pcpgfpxstuff.h"
+#include "pcpmask_ct.h"
#define _LEGACY_ECCP_SUPPORT_
@@ -74,7 +99,7 @@ typedef struct _cpGFpECPoint {
//#define ECP_PROJECTIVE_COORD HOMOGENEOUS
#if (ECP_PROJECTIVE_COORD== JACOBIAN)
- //#pragma message ("ECP_PROJECTIVE_COORD = JACOBIAN")
+ #pragma message ("ECP_PROJECTIVE_COORD = JACOBIAN")
#elif (ECP_PROJECTIVE_COORD== HOMOGENEOUS)
#pragma message ("ECP_PROJECTIVE_COORD = HOMOGENEOUS")
#else
@@ -100,6 +125,7 @@ typedef struct _cpGFpEC {
IppsGFpState* pGF; /* arbitrary GF(p^d)*/
+ int subgroup; /* set up subgroup */
int elementSize; /* length of EC point */
int orderBitSize; /* base_point order bitsize */
BNU_CHUNK_T* pA; /* EC parameter A */
@@ -130,6 +156,7 @@ typedef struct _cpGFpEC {
#define ECP_ID(pCtx) ((pCtx)->idCtx)
#define ECP_GFP(pCtx) ((pCtx)->pGF)
+#define ECP_SUBGROUP(pCtx) ((pCtx)->subgroup)
#define ECP_POINTLEN(pCtx) ((pCtx)->elementSize)
#define ECP_ORDBITSIZE(pCtx) ((pCtx)->orderBitSize)
#define ECP_COFACTOR(pCtx) ((pCtx)->cofactor)
@@ -231,7 +258,7 @@ __INLINE int gfec_IsPointAtInfinity(const IppsGFpECPoint* pPoint)
/* signed encode */
__INLINE void booth_recode(Ipp8u* sign, Ipp8u* digit, Ipp8u in, int w)
{
- Ipp8u s = ~((in >> w) - 1);
+ Ipp8u s = (Ipp8u)(~((in >> w) - 1));
int d = (1 << (w+1)) - in - 1;
d = (d & s) | (in & ~s);
d = (d >> 1) + (d & 1);
@@ -239,49 +266,30 @@ __INLINE void booth_recode(Ipp8u* sign, Ipp8u* digit, Ipp8u in, int w)
*digit = (Ipp8u)d;
}
-/* returns 1/0 if x==0/!=0 */
-__INLINE BNU_CHUNK_T isZero(BNU_CHUNK_T x)
-{
- #if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT)
- x |= x<<32;
- #endif
- x |= x<<16;
- x |= x<<8;
- x |= x<<4;
- x |= x<<2;
- x |= x<<1;
- x = ~x;
- x>>=BNU_CHUNK_BITS-1;
- return x;
-}
-
-/* mask of the argument:
- if x==0 returns 0
- if x!=0 returns BNU_CHUNK_T(-1)
-*/
-__INLINE BNU_CHUNK_T cpIsNonZeroMask(BNU_CHUNK_T x)
-{
- #if(_IPP_ARCH==_IPP_ARCH_EM64T)
- x |= x>>32;
- #endif
- x |= x>>16;
- x |= x>>8;
- x |= x>>4;
- x |= x>>2;
- x |= x>>1;
- return 0-(x&1);
-}
-
-/* dst[] = src[], iif moveFlag!=0 */
-__INLINE void cpMaskMove(BNU_CHUNK_T* dst, const BNU_CHUNK_T* src, int len, int moveFlag)
-{
- BNU_CHUNK_T mask1 = cpIsNonZeroMask(moveFlag);
- BNU_CHUNK_T mask2 = ~mask1;
- int n;
- for(n=0; n<len; n++)
- dst[n] = (src[n] & mask1) ^ (dst[n] & mask2);
-}
+#define gfec_point_add OWNAPI(gfec_point_add)
+void gfec_point_add (BNU_CHUNK_T* pRdata,
+ const BNU_CHUNK_T* pPdata,
+ const BNU_CHUNK_T* pQdata, IppsGFpECState* pEC);
+#define gfec_affine_point_add OWNAPI(gfec_affine_point_add)
+void gfec_affine_point_add(BNU_CHUNK_T* pRdata,
+ const BNU_CHUNK_T* pPdata,
+ const BNU_CHUNK_T* pAdata, IppsGFpECState* pEC);
+#define gfec_point_double OWNAPI(gfec_point_double)
+void gfec_point_double (BNU_CHUNK_T* pRdata,
+ const BNU_CHUNK_T* pPdata, IppsGFpECState* pEC);
+#define gfec_point_mul OWNAPI(gfec_point_mul)
+void gfec_point_mul (BNU_CHUNK_T* pRdata,
+ const BNU_CHUNK_T* pPdata, const Ipp8u* pScalar8, int scalarBitSize, IppsGFpECState* pEC, Ipp8u* pScratchBuffer);
+#define gfec_point_prod OWNAPI(gfec_point_prod)
+void gfec_point_prod (BNU_CHUNK_T* pointR,
+ const BNU_CHUNK_T* pointA, const Ipp8u* pScalarA,
+ const BNU_CHUNK_T* pointB, const Ipp8u* pScalarB, int scalarBitSize, IppsGFpECState* pEC, Ipp8u* pScratchBuffer);
+#define gfec_base_point_mul OWNAPI(gfec_base_point_mul)
+void gfec_base_point_mul (BNU_CHUNK_T* pRdata, const Ipp8u* pScalarB, int scalarBitSize, IppsGFpECState* pEC);
+#define setupTable OWNAPI(setupTable)
+void setupTable (BNU_CHUNK_T* pTbl,
+ const BNU_CHUNK_T* pPdata, IppsGFpECState* pEC);
/* size of context */
@@ -300,15 +308,27 @@ __INLINE void cpMaskMove(BNU_CHUNK_T* dst, const BNU_CHUNK_T* src, int len, int
#define gfec_IsPointOnCurve OWNAPI(gfec_IsPointOnCurve)
int gfec_IsPointOnCurve(const IppsGFpECPoint* pP, IppsGFpECState* pEC);
+__INLINE IppsGFpECPoint* gfec_DblPoint(IppsGFpECPoint* pR,
+ const IppsGFpECPoint* pP, IppsGFpECState* pEC)
+{
+ gfec_point_double(ECP_POINT_X(pR), ECP_POINT_X(pP), pEC);
+ ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
+ return pR;
+}
+
+__INLINE IppsGFpECPoint* gfec_AddPoint(IppsGFpECPoint* pR,
+ const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ,
+ IppsGFpECState* pEC)
+{
+ gfec_point_add(ECP_POINT_X(pR), ECP_POINT_X(pP), ECP_POINT_X(pQ), pEC);
+ ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
+ return pR;
+}
+
+
#define gfec_NegPoint OWNAPI(gfec_NegPoint)
IppsGFpECPoint* gfec_NegPoint(IppsGFpECPoint* pR,
const IppsGFpECPoint* pP, IppsGFpECState* pEC);
-#define gfec_DblPoint OWNAPI(gfec_DblPoint)
-IppsGFpECPoint* gfec_DblPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, IppsGFpECState* pEC);
-#define gfec_AddPoint OWNAPI(gfec_AddPoint)
-IppsGFpECPoint* gfec_AddPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECState* pEC);
#define gfec_MulPoint OWNAPI(gfec_MulPoint)
IppsGFpECPoint* gfec_MulPoint(IppsGFpECPoint* pR,
const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalar, int scalarLen,
@@ -317,11 +337,11 @@ IppsGFpECPoint* gfec_MulPoint(IppsGFpECPoint* pR,
IppsGFpECPoint* gfec_MulBasePoint(IppsGFpECPoint* pR,
const BNU_CHUNK_T* pScalar, int scalarLen,
IppsGFpECState* pEC, Ipp8u* pScratchBuffer);
-#define gfec_PointProduct OWNAPI(gfec_PointProduct)
-IppsGFpECPoint* gfec_PointProduct(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalarP, int scalarPlen,
- const IppsGFpECPoint* pQ, const BNU_CHUNK_T* pScalarQ, int scalarQlen,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer);
+//#define gfec_PointProduct OWNAPI(gfec_PointProduct)
+//IppsGFpECPoint* gfec_PointProduct(IppsGFpECPoint* pR,
+// const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalarP, int scalarPlen,
+// const IppsGFpECPoint* pQ, const BNU_CHUNK_T* pScalarQ, int scalarQlen,
+// IppsGFpECState* pEC, Ipp8u* pScratchBuffer);
#define gfec_BasePointProduct OWNAPI(gfec_BasePointProduct)
IppsGFpECPoint* gfec_BasePointProduct(IppsGFpECPoint* pR,
const BNU_CHUNK_T* pScalarG, int scalarGlen,
diff --git a/ext/ipp/sources/ippcp/pcpgfpectstpoint.c b/ext/ipp/sources/ippcp/pcpgfpectstpoint.c
new file mode 100644
index 0000000..0d7f37b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpectstpoint.c
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECTstPoint()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+/*F*
+// Name: ippsGFpECTstPoint
+//
+// Purpose: Checks if a point belongs to an elliptic curve
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pEC == NULL
+// pResult == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// invalid pP->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pResult Pointer to the result of the check
+//
+// Note:
+// Even if test passed is not a fact that the point belongs to BP-related subgroup BP
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP,
+ IppECResult* pResult,
+ IppsGFpECState* pEC))
+{
+ IPP_BAD_PTR3_RET(pP, pResult, pEC);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ if( gfec_IsPointAtInfinity(pP) )
+ *pResult = ippECPointIsAtInfinite;
+ else if( !gfec_IsPointOnCurve(pP, pEC) )
+ *pResult = ippECPointIsNotValid;
+ else
+ *pResult = ippECValid;
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpectstpointinsubgroup.c b/ext/ipp/sources/ippcp/pcpgfpectstpointinsubgroup.c
new file mode 100644
index 0000000..43dcb24
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpectstpointinsubgroup.c
@@ -0,0 +1,115 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p) Operations
+//
+// Context:
+// ippsGFpECTstPointInSubgroup()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+
+/*F*
+// Name: ippsGFpECTstPointInSubgroup
+//
+// Purpose: Checks if a point belongs to a specified subgroup
+//
+// Returns: Reason:
+// ippStsNullPtrErr pP == NULL
+// pEC == NULL
+// pResult == NULL
+/ pScratchBuffer == NULL
+//
+// ippStsContextMatchErr invalid pEC->idCtx
+// pEC->subgroup == NULL
+// invalid pP->idCtx
+//
+// ippStsOutOfRangeErr ECP_POINT_FELEN(pP)!=GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pP Pointer to the IppsGFpECPoint context
+// pEC Pointer to the context of the elliptic curve
+// pResult Pointer to the result of the check
+// pScratchBuffer Pointer to the scratch buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECTstPointInSubgroup,(const IppsGFpECPoint* pP,
+ IppECResult* pResult,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IPP_BAD_PTR4_RET(pP, pResult, pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
+
+ {
+ IppECResult tstResult;
+ ippsGFpECTstPoint(pP, &tstResult, pEC);
+
+ if(ippECValid==tstResult) {
+ IppsGFpECPoint T;
+ cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
+
+ gfec_MulPoint(&T, pP, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), /*0,*/ pEC, pScratchBuffer);
+ tstResult = gfec_IsPointAtInfinity(&T)? ippECValid : ippECPointOutOfGroup;
+
+ cpEcGFpReleasePool(1, pEC);
+ }
+ *pResult = tstResult;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecverify.c b/ext/ipp/sources/ippcp/pcpgfpecverify.c
new file mode 100644
index 0000000..c7a21d7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecverify.c
@@ -0,0 +1,166 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// EC over GF(p^m) definitinons
+//
+// Context:
+// ippsGFpECVerify()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpecstuff.h"
+#include "pcpeccp.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+/*F*
+// Name: ippsGFpECVerify
+//
+// Purpose: Verifies the parameters of an elliptic curve.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pEC == NULL
+// pResult == NULL
+// pScratchBuffer == NULL
+// ippStsContextMatchErr invalid pEC->idCtx
+// ippStsNoErr no error
+//
+// Parameters:
+// pResult Pointer to the verification result
+// pEC Pointer to the context of the elliptic curve
+// pScratchBuffer Pointer to the scratch buffer
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpECVerify,(IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
+{
+ IPP_BAD_PTR3_RET(pEC, pResult, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
+
+ *pResult = ippECValid;
+
+ {
+ IppsGFpState* pGF = ECP_GFP(pEC);
+ gsModEngine* pGFE = GFP_PMA(pGF);
+ int elemLen = GFP_FELEN(pGFE);
+
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGFE)->add;
+
+ /*
+ // check discriminant ( 4*A^3 + 27*B^2 != 0 mod P)
+ */
+ if(ippECValid == *pResult) {
+ BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
+ BNU_CHUNK_T* pU = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(NULL!=pT && NULL!=pU);
+
+ if(ECP_SPECIFIC(pEC)==ECP_EPID2)
+ cpGFpElementPadd(pT, elemLen, 0); /* T = 4*A^3 = 0 */
+ else {
+ addF(pT, ECP_A(pEC), ECP_A(pEC), pGFE); /* T = 4*A^3 */
+ sqrF(pT, pT, pGFE);
+ mulF(pT, ECP_A(pEC), pT, pGFE);
+ }
+
+ addF(pU, ECP_B(pEC), ECP_B(pEC), pGFE); /* U = 9*B^2 */
+ addF(pU, pU, ECP_B(pEC), pGFE);
+ sqrF(pU, pU, pGFE);
+
+ addF(pT, pU, pT, pGFE); /* T += 3*U */
+ addF(pT, pU, pT, pGFE);
+ addF(pT, pU, pT, pGFE);
+
+ *pResult = GFP_IS_ZERO(pT, elemLen)? ippECIsZeroDiscriminant: ippECValid;
+
+ cpGFpReleasePool(2, pGFE);
+ }
+
+ if(ECP_SUBGROUP(pEC)) {
+ /*
+ // check base point and it order
+ */
+ if(ippECValid == *pResult) {
+ IppsGFpECPoint G;
+ cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
+
+ /* check G != infinity */
+ *pResult = gfec_IsPointAtInfinity(&G)? ippECPointIsAtInfinite : ippECValid;
+
+ /* check G lies on EC */
+ if(ippECValid == *pResult)
+ *pResult = gfec_IsPointOnCurve(&G, pEC)? ippECValid : ippECPointIsNotValid;
+
+ /* check Gorder*G = infinity */
+ if(ippECValid == *pResult) {
+ IppsGFpECPoint T;
+ cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
+
+ gfec_MulBasePoint(&T, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer);
+
+ *pResult = gfec_IsPointAtInfinity(&T)? ippECValid : ippECInvalidOrder;
+
+ cpEcGFpReleasePool(1, pEC);
+ }
+ }
+
+ /*
+ // check order==P
+ */
+ if(ippECValid == *pResult) {
+ BNU_CHUNK_T* pPrime = GFP_MODULUS(pGFE);
+ int primeLen = GFP_FELEN(pGFE);
+
+ gsModEngine* pR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pR);
+ int orderLen = MOD_LEN(pR);
+
+ *pResult = (primeLen==orderLen && GFP_EQ(pPrime, pOrder, primeLen))? ippECIsWeakSSSA : ippECValid;
+ }
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecverifydsa.c b/ext/ipp/sources/ippcp/pcpgfpecverifydsa.c
new file mode 100644
index 0000000..73feab3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecverifydsa.c
@@ -0,0 +1,201 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECVerifyDSA()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECVerifyDSA
+//
+// Purpose: DSA Signature Verification.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPublic
+// NULL == pSignR
+// NULL == pSignS
+// NULL == pResult
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pECC->idCtx
+// pEC->subgroup == NULL
+// illegal pMsgDigestDigest->idCtx
+// illegal pRegPublic->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsMessageErr 0> MsgDigest
+// order<= MsgDigest
+//
+// ippStsRangeErr SignR < 0 or SignS < 0
+//
+// ippStsOutOfRangeErr bitsize(pRegPublic) != bitsize(prime)
+//
+// ippStsNotSupportedModeErr 1<GFP_EXTDEGREE(pGFE)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to being signed
+// pRegPublic pointer to the regular public key
+// pSignR,pSignS pointer to the signature
+// pResult pointer to the result: ippECValid/ippECInvalidSignature
+// pEC pointer to the ECCP context
+// pScratchBuffer pointer to buffer (2 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECVerifyDSA,(const IppsBigNumState* pMsgDigest,
+ const IppsGFpECPoint* pRegPublic,
+ const IppsBigNumState* pSignR, const IppsBigNumState* pSignS,
+ IppECResult* pResult,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+ IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test regular public key */
+ IPP_BAD_PTR1_RET(pRegPublic);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
+ IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignR, pSignS);
+ pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, ALIGN_VAL) );
+ pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignR), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignS), ippStsRangeErr);
+
+ /* test result */
+ IPP_BAD_PTR1_RET(pResult);
+
+ {
+ IppECResult vResult = ippECInvalidSignature;
+
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int orderLen = MOD_LEN(pMontR);
+
+ /* test mesage: msg<order */
+ IPP_BADARG_RET((0<=cpCmp_BNU(BN_NUMBER(pMsgDigest), BN_SIZE(pMsgDigest), pOrder, orderLen)), ippStsMessageErr);
+
+ /* test signature value */
+ if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignR), BN_SIZE(pSignR), 0) &&
+ !cpEqu_BNU_CHUNK(BN_NUMBER(pSignS), BN_SIZE(pSignS), 0) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignR), BN_SIZE(pSignR), pOrder, orderLen) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignS), BN_SIZE(pSignS), pOrder, orderLen)) {
+
+ int elmLen = GFP_FELEN(pGFE);
+ int pelmLen = GFP_PELEN(pGFE);
+
+ BNU_CHUNK_T* h1 = cpGFpGetPool(3, pGFE);
+ BNU_CHUNK_T* h2 = h1+pelmLen;
+ BNU_CHUNK_T* h = h2+pelmLen;
+
+ //BNU_CHUNK_T* buffMsg = BN_BUFFER(pMsgDigest);
+
+ IppsGFpECPoint P;
+ cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
+
+ /* copy message */
+ ZEXPAND_COPY_BNU(h1, orderLen, BN_NUMBER(pMsgDigest), BN_SIZE(pMsgDigest));
+
+ /* h = d^-1, h1 = msg*h, h2 = c*h */
+ ZEXPAND_COPY_BNU(h, orderLen, BN_NUMBER(pSignS),BN_SIZE(pSignS));
+ gs_mont_inv(h, h, pMontR, alm_mont_inv);
+
+ cpMontMul_BNU(h1, h, h1, pMontR);
+ ZEXPAND_COPY_BNU(h2, orderLen, BN_NUMBER(pSignR),BN_SIZE(pSignR));
+ cpMontMul_BNU(h2, h, h2, pMontR);
+
+ /* P = [h1]BasePoint + [h2]publicKey */
+ gfec_BasePointProduct(&P,
+ h1, orderLen, pRegPublic, h2, orderLen,
+ pEC, pScratchBuffer);
+
+ /* get P.X */
+ if(gfec_GetPoint(h1, NULL, &P, pEC)) {
+ /* c' = int(P.x) mod order */
+ GFP_METHOD(pGFE)->decode(h1, h1, pGFE);
+ elmLen = cpMod_BNU(h1, elmLen, pOrder, orderLen);
+ cpGFpElementPadd(h1+elmLen, orderLen-elmLen, 0);
+
+ /* and make sure c' = signC */
+ cpGFpElementCopyPadd(h2, orderLen, BN_NUMBER(pSignR), BN_SIZE(pSignR));
+ if(GFP_EQ(h1, h2, orderLen))
+ vResult = ippECValid;
+ }
+
+ cpEcGFpReleasePool(1, pEC);
+ cpGFpReleasePool(3, pGFE);
+ }
+
+ *pResult = vResult;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpecverifynr.c b/ext/ipp/sources/ippcp/pcpgfpecverifynr.c
new file mode 100644
index 0000000..2835182
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpecverifynr.c
@@ -0,0 +1,191 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// ippsGFpECVerifyNR()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpeccp.h"
+
+/*F*
+// Name: ippsGFpECVerifyNR
+//
+// Purpose: NR Signature Verification.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pEC
+// NULL == pMsgDigest
+// NULL == pRegPublic
+// NULL == pSignR
+// NULL == pSignS
+// NULL == pResult
+// NULL == pScratchBuffer
+//
+// ippStsContextMatchErr illegal pEC->idCtx
+// pEC->subgroup == NULL
+// illegal pMsgDigestDigest->idCtx
+// illegal pRegPublic->idCtx
+// illegal pSignR->idCtx
+// illegal pSignS->idCtx
+//
+// ippStsMessageErr 0> MsgDigest
+// order<= MsgDigest
+//
+// ippStsRangeErr SignR < 0 or SignS < 0
+//
+// ippStsOutOfRangeErr bitsize(pRegPublic) != bitsize(prime)
+//
+// ippStsNotSupportedModeErr 1<GFP_EXTDEGREE(pGFE)
+//
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsgDigest pointer to the message representative to being signed
+// pRegPublic pointer to the regular public key
+// pSignR,pSignS pointer to the signature
+// pResult pointer to the result: ippECValid/ippECInvalidSignature
+// pEC pointer to the ECCP context
+// pScratchBuffer pointer to buffer (2 mul_point operation)
+//
+*F*/
+IPPFUN(IppStatus, ippsGFpECVerifyNR,(const IppsBigNumState* pMsgDigest,
+ const IppsGFpECPoint* pRegPublic,
+ const IppsBigNumState* pSignR, const IppsBigNumState* pSignS,
+ IppECResult* pResult,
+ IppsGFpECState* pEC,
+ Ipp8u* pScratchBuffer))
+{
+ IppsGFpState* pGF;
+ gsModEngine* pGFE;
+
+ /* EC context and buffer */
+ IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
+ pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
+ IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
+ IPP_BADARG_RET(!ECP_SUBGROUP(pEC), ippStsContextMatchErr);
+
+ pGF = ECP_GFP(pEC);
+ pGFE = GFP_PMA(pGF);
+ IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
+
+ /* test message representative */
+ IPP_BAD_PTR1_RET(pMsgDigest);
+ pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
+
+ /* test regular public key */
+ IPP_BAD_PTR1_RET(pRegPublic);
+ IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
+ IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ /* test signature */
+ IPP_BAD_PTR2_RET(pSignR, pSignS);
+ pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, ALIGN_VAL) );
+ pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, ALIGN_VAL) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignR), ippStsRangeErr);
+ IPP_BADARG_RET(BN_NEGATIVE(pSignS), ippStsRangeErr);
+
+ /* test result */
+ IPP_BAD_PTR1_RET(pResult);
+
+ {
+ IppECResult vResult = ippECInvalidSignature;
+
+ gsModEngine* pMontR = ECP_MONT_R(pEC);
+ BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
+ int orderLen = MOD_LEN(pMontR);
+
+ /* test mesage: msg<order */
+ IPP_BADARG_RET((0<=cpCmp_BNU(BN_NUMBER(pMsgDigest), BN_SIZE(pMsgDigest), pOrder, orderLen)), ippStsMessageErr);
+
+ /* test signature value */
+ if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignR), BN_SIZE(pSignR), 0) &&
+ !cpEqu_BNU_CHUNK(BN_NUMBER(pSignS), BN_SIZE(pSignS), 0) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignR), BN_SIZE(pSignR), pOrder, orderLen) &&
+ 0>cpCmp_BNU(BN_NUMBER(pSignS), BN_SIZE(pSignS), pOrder, orderLen)) {
+
+ int elmLen = GFP_FELEN(pGFE);
+ int pelmLen = GFP_PELEN(pGFE);
+
+ BNU_CHUNK_T* h1 = cpGFpGetPool(3, pGFE);
+ BNU_CHUNK_T* h2 = h1+pelmLen;
+ BNU_CHUNK_T* f = h2+pelmLen;
+
+ IppsGFpECPoint P;
+ cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
+
+ /* P = [d]BasePoint + [c]publicKey */
+ ZEXPAND_COPY_BNU(h1, orderLen, BN_NUMBER(pSignS),BN_SIZE(pSignS));
+ ZEXPAND_COPY_BNU(h2, orderLen, BN_NUMBER(pSignR),BN_SIZE(pSignR));
+ gfec_BasePointProduct(&P,
+ h1, orderLen, pRegPublic, h2, orderLen,
+ pEC, pScratchBuffer);
+
+ /* get P.X */
+ if(gfec_GetPoint(h1, NULL, &P, pEC)) {
+ /* x = int(P.x) mod order */
+ GFP_METHOD(pGFE)->decode(h1, h1, pGFE);
+ elmLen = cpMod_BNU(h1, elmLen, pOrder, orderLen);
+ cpGFpElementPadd(h1+elmLen, orderLen-elmLen, 0);
+
+ /* and recover msg f = (signC -x) mod order */
+ ZEXPAND_COPY_BNU(f, orderLen, BN_NUMBER(pMsgDigest),BN_SIZE(pMsgDigest));
+ cpModSub_BNU(h1, h2, h1, pOrder, orderLen, h2);
+ if(GFP_EQ(f, h1, orderLen))
+ vResult = ippECValid;
+ }
+
+ cpEcGFpReleasePool(1, pEC);
+ cpGFpReleasePool(3, pGFE);
+ }
+
+ *pResult = vResult;
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpelemgetsize.c b/ext/ipp/sources/ippcp/pcpgfpelemgetsize.c
new file mode 100644
index 0000000..f8b6751
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpelemgetsize.c
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpElementGetSize()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: ippsGFpElementGetSize
+//
+// Purpose: Gets the size of the context for an element of the finite field.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pGFp == NULL
+// pBufferSize == NULL
+// ippStsContextMatchErr incorrect pGFp's context id
+// ippStsNoErr no error
+//
+// Parameters:
+// nExponents Number of exponents.
+// ExpBitSize Maximum bit size of the exponents.
+// pGFp Pointer to the context of the finite field.
+// pBufferSize Pointer to the calculated buffer size in bytes.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpElementGetSize,(const IppsGFpState* pGFp, int* pElementSize))
+{
+ IPP_BAD_PTR2_RET(pElementSize, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ *pElementSize = sizeof(IppsGFpElement)
+ +GFP_FELEN(GFP_PMA(pGFp))*sizeof(BNU_CHUNK_T);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpeleminit.c b/ext/ipp/sources/ippcp/pcpgfpeleminit.c
new file mode 100644
index 0000000..c44efb9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpeleminit.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpElementInit()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: ippsGFpElementInit
+//
+// Purpose: Initializes the context of an element of the finite field.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pGFp == NULL
+// pR == NULL
+// pA && nsA>0 == NULL
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pR->idCtx
+//
+// ippStsSizeErr pA && !(0<=lenA && lenA<GFP_FELEN32(GFP_PMA(pGFp)))
+//
+// ippStsOutOfRangeErr GFPE_ROOM(pR)!=GFP_FELEN(GFP_PMA(pGFp)
+// BNU representation of pA[i]..pA[i+GFP_FELEN32()-1] >= modulus
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the data array storing the finite field element.
+// lenA Length of the element.
+// pR Pointer to the context of the finite field element being initialized.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpElementInit,(const Ipp32u* pA, int lenA, IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR2_RET(pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+
+ IPP_BADARG_RET(0>lenA, ippStsSizeErr);
+
+ {
+ int elemLen = GFP_FELEN(GFP_PMA(pGFp));
+
+ Ipp8u* ptr = (Ipp8u*)pR;
+ ptr += sizeof(IppsGFpElement);
+ cpGFpElementConstruct(pR, (BNU_CHUNK_T*)ptr, elemLen);
+ return ippsGFpSetElement(pA, lenA, pR, pGFp);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpexp.c b/ext/ipp/sources/ippcp/pcpgfpexp.c
new file mode 100644
index 0000000..ec82719
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpexp.c
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpExp()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpExp
+//
+// Purpose: Raise GF element to the specified power
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pE
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pE->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pE Pointer to the Big Number context storing the exponent
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+// pScratchBuffer Pointer to the scratch buffer.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpExp,(const IppsGFpElement* pA, const IppsBigNumState* pE,
+ IppsGFpElement* pR, IppsGFpState* pGFp,
+ Ipp8u* pScratchBuffer))
+{
+ IPP_BAD_PTR4_RET(pA, pE, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+
+ pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
+ IPP_BADARG_RET( !BN_VALID_ID(pE), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ cpGFpxExp(GFPE_DATA(pR), GFPE_DATA(pA), BN_NUMBER(pE), BN_SIZE(pE), pGFE, pScratchBuffer);
+ return ippStsNoErr;
+ }
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpgfpgetelem.c b/ext/ipp/sources/ippcp/pcpgfpgetelem.c
new file mode 100644
index 0000000..fdee798
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpgetelem.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpGetElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: ippsGFpGetElement
+//
+// Purpose: Get GF Element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pDataA
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsSizeErr !(0<lenA && lenA>=GFP_FELEN32(pGFE))
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the finite field element.
+// pDataA Pointer to the data array to copy the finite field element from.
+// lenA Length of the data array.
+// pGFp Pointer to the context of the finite field.
+*F*/
+
+IPPFUN(IppStatus, ippsGFpGetElement, (const IppsGFpElement* pA, Ipp32u* pDataA, int lenA, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pDataA, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( !(0<lenA && lenA>=GFP_FELEN32(pGFE)), ippStsSizeErr );
+
+ {
+ int elemLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(NULL!=pTmp);
+
+ cpGFpxGet(pTmp, elemLen, GFPE_DATA(pA), pGFE);
+ cpGFpxCopyFromChunk(pDataA, pTmp, pGFE);
+
+ cpGFpReleasePool(1, pGFE);
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpgetelemoctstr.c b/ext/ipp/sources/ippcp/pcpgfpgetelemoctstr.c
new file mode 100644
index 0000000..b023fdd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpgetelemoctstr.c
@@ -0,0 +1,115 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpGetElementOctString()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpGetElementOctString
+//
+// Purpose: Get GF Element to the octet string
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pStr
+// NULL == pA
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsSizeErr !(0<lenA && lenA>=GFP_FELEN32(pGFE))
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the finite field element.
+// pStr Pointer to the octet string.
+// strSize Size of the octet string buffer in bytes.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpGetElementOctString,(const IppsGFpElement* pA, Ipp8u* pStr, int strSize, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pStr, pA, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( 0>=strSize, ippStsSizeErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFE);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGFE),GFP_FELEN(pBasicGFE)));
+
+ BNU_CHUNK_T* pDataElm = GFPE_DATA(pA);
+ int deg, error;
+ for(deg=0, error=0; deg<basicDeg && !error; deg++) {
+ int size = IPP_MIN(strSize, basicSize);
+ error = (NULL == cpGFpGetOctString(pStr, size, pDataElm, pBasicGFE));
+
+ pDataElm += basicElemLen;
+ pStr += size;
+ strSize -= size;
+ }
+
+ return error ? ippStsSizeErr : ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpgetsize.c b/ext/ipp/sources/ippcp/pcpgfpgetsize.c
new file mode 100644
index 0000000..5bd9a74
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpgetsize.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpGetSize()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpGetSize
+//
+// Purpose: Gets the size of the context of a GF(q) field
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL.
+// ippStsSizeErr bitSize is less than 2 or greater than 1024.
+// ippStsNoErr no error
+//
+// Parameters:
+// feBitSize Size, in bytes, of the odd prime number q (modulus of GF(q)).
+// pSize Pointer to the buffer size, in bytes, needed for the IppsGFpState
+// context. //
+*F*/
+
+IPPFUN(IppStatus, ippsGFpGetSize,(int feBitSize, int* pSize))
+{
+ IPP_BAD_PTR1_RET(pSize);
+ IPP_BADARG_RET((feBitSize < 2) || (feBitSize > GFP_MAX_BITSIZE), ippStsSizeErr);
+
+ *pSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE)
+ + GFP_ALIGNMENT;
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpinit.c b/ext/ipp/sources/ippcp/pcpgfpinit.c
new file mode 100644
index 0000000..6c71bc7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpinit.c
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpInit
+//
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpInit
+//
+// Purpose: initializes prime finite field GF(p)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFpMethod
+// NULL == pGFp
+//
+// ippStsSizeErr !(IPP_MIN_GF_BITSIZE <= primeBitSize <=IPP_MAX_GF_BITSIZE
+//
+// ippStsContextMatchErr invalid pPrime->idCtx
+//
+// ippStsBadArgErr pGFpMethod != ippsGFpMethod_pXXX() or != ippsGFpMethod_pArb()
+// prime != pGFpMethod->modulus
+// prime <0
+// bitsize(prime) != primeBitSize
+// prime <IPP_MIN_GF_CHAR
+// prime is even
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPrimeBN pointer to the data representation Finite Field element
+// primeBitSize length of Finite Field data representation array
+// pGFpMethod pointer to Finite Field Element context
+// pGFp pointer to Finite Field context is being initialized
+*F*/
+IPPFUN(IppStatus, ippsGFpInit,(const IppsBigNumState* pPrimeBN, int primeBitSize, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFp))
+{
+ IPP_BADARG_RET(!pPrimeBN && !pGFpMethod, ippStsNullPtrErr);
+
+ IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
+
+ /* use ippsGFpInitFixed() if NULL==pPrimeBN */
+ if(!pPrimeBN)
+ return ippsGFpInitFixed(primeBitSize, pGFpMethod, pGFp);
+
+ /* use ippsGFpInitArbitrary() if NULL==pGFpMethod */
+ if(!pGFpMethod)
+ return ippsGFpInitArbitrary(pPrimeBN, primeBitSize, pGFp);
+
+ /* test parameters if both pPrimeBN and method are defined */
+ else {
+ IppStatus sts;
+
+ /* test input prime */
+ pPrimeBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrimeBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrimeBN), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_SIGN(pPrimeBN)!= IppsBigNumPOS, ippStsBadArgErr); /* prime is negative */
+ IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrimeBN),BN_SIZE(pPrimeBN)) != primeBitSize, ippStsBadArgErr); /* primeBitSize == bitsize(prime) */
+ IPP_BADARG_RET((BN_SIZE(pPrimeBN)==1) && (BN_NUMBER(pPrimeBN)[0]<IPP_MIN_GF_CHAR), ippStsBadArgErr); /* prime < 3 */
+ IPP_BADARG_RET(0==(BN_NUMBER(pPrimeBN)[0] & 1), ippStsBadArgErr); /* prime is even */
+
+ /* test if method is prime based */
+ IPP_BADARG_RET(cpID_Prime!=(pGFpMethod->modulusID & cpID_Prime), ippStsBadArgErr);
+
+ /* test if size of the prime is matched to method's prime */
+ IPP_BADARG_RET(pGFpMethod->modulusBitDeg && (primeBitSize!=pGFpMethod->modulusBitDeg), ippStsBadArgErr);
+
+ /* if method assumes fixed prime value */
+ if(pGFpMethod->modulus) {
+ int primeLen = BITS_BNU_CHUNK(primeBitSize);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pPrimeBN), primeLen, pGFpMethod->modulus, primeLen), ippStsBadArgErr);
+ }
+
+ /* init GF */
+ sts = cpGFpInitGFp(primeBitSize, pGFp);
+
+ /* set up GF and find quadratic nonresidue */
+ if(ippStsNoErr==sts) {
+ cpGFpSetGFp(BN_NUMBER(pPrimeBN), primeBitSize, pGFpMethod, pGFp);
+ }
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpinitarbitrary.c b/ext/ipp/sources/ippcp/pcpgfpinitarbitrary.c
new file mode 100644
index 0000000..809e817
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpinitarbitrary.c
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpInitArbitrary()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpInitArbitrary
+//
+// Purpose: initializes prime finite field GF(p)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pPrime
+// NULL == pGFp
+//
+// ippStsSizeErr !(IPP_MIN_GF_BITSIZE <= primeBitSize <=IPP_MAX_GF_BITSIZE)
+//
+// ippStsContextMatchErr incorrect pPrime context ID
+//
+// ippStsBadArgErr prime <0
+// bitsize(prime) != primeBitSize
+// prime <IPP_MIN_GF_CHAR
+// prime is even
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pPrime pointer to the prime context
+// primeBitSize length of prime in bits
+// pGFp pointer to Finite Field context is being initialized
+*F*/
+IPPFUN(IppStatus, ippsGFpInitArbitrary,(const IppsBigNumState* pPrime, int primeBitSize, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR1_RET(pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+
+ IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
+
+ IPP_BAD_PTR1_RET(pPrime);
+ pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
+ IPP_BADARG_RET(BN_SIGN(pPrime)!= IppsBigNumPOS, ippStsBadArgErr); /* prime is negative */
+ IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrime),BN_SIZE(pPrime)) != primeBitSize, ippStsBadArgErr); /* primeBitSize == bitsize(prime) */
+ IPP_BADARG_RET((BN_SIZE(pPrime)==1) && (BN_NUMBER(pPrime)[0]<IPP_MIN_GF_CHAR), ippStsBadArgErr); /* prime < 3 */
+ IPP_BADARG_RET(0==(BN_NUMBER(pPrime)[0] & 1), ippStsBadArgErr); /* prime is even */
+
+ {
+ /* init GF */
+ IppStatus sts = cpGFpInitGFp(primeBitSize, pGFp);
+
+ /* set up GF engine */
+ if(ippStsNoErr==sts) {
+ cpGFpSetGFp(BN_NUMBER(pPrime), primeBitSize, ippsGFpMethod_pArb(), pGFp);
+ }
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpinitfixed.c b/ext/ipp/sources/ippcp/pcpgfpinitfixed.c
new file mode 100644
index 0000000..3596911
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpinitfixed.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpInitFixed()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpInitFixed
+//
+// Purpose: initializes prime finite field GF(p)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFpMethod
+// NULL == pGFp
+//
+// ippStsBadArgErr pGFpMethod != ippsGFpMethod_pXXX() any fixed prime method
+// primeBitSize != sizeof modulus defined by fixed method
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// primeBitSize length of prime in bits
+// pGFpMethod pointer to the basic arithmetic metods
+// pGFp pointer to Finite Field context is being initialized
+*F*/
+IPPFUN(IppStatus, ippsGFpInitFixed,(int primeBitSize, const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR2_RET(pGFpMethod, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+
+ /* test method is prime based */
+ IPP_BADARG_RET(cpID_Prime!=(pGFpMethod->modulusID & cpID_Prime), ippStsBadArgErr);
+ /* test if method is not prime based arbitrary */
+ IPP_BADARG_RET(!pGFpMethod->modulus, ippStsBadArgErr);
+ /* size of the underlying prime must be equal to primeBitSize parameter*/
+ IPP_BADARG_RET(pGFpMethod->modulusBitDeg!=primeBitSize, ippStsBadArgErr);
+
+ {
+ /* init GF */
+ IppStatus sts = cpGFpInitGFp(primeBitSize, pGFp);
+
+ /* set up GF engine */
+ if(ippStsNoErr==sts) {
+ cpGFpSetGFp(pGFpMethod->modulus, primeBitSize, pGFpMethod, pGFp);
+ }
+
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpinv.c b/ext/ipp/sources/ippcp/pcpgfpinv.c
new file mode 100644
index 0000000..46969f6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpinv.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpInv()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpInv
+//
+// Purpose: Multiplicative inverse GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsDivByZeroErr pA is zero
+//
+// ippStsBadArgErr computational error
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the source finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpInv,(const IppsGFpElement* pA,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( GFP_IS_ZERO(GFPE_DATA(pA),GFP_FELEN(pGFE)), ippStsDivByZeroErr );
+
+ return NULL != cpGFpxInv(GFPE_DATA(pR), GFPE_DATA(pA), pGFE)? ippStsNoErr : ippStsBadArgErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpisunityelem.c b/ext/ipp/sources/ippcp/pcpgfpisunityelem.c
new file mode 100644
index 0000000..b616135
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpisunityelem.c
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpIsUnityElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpIsUnityElement
+//
+// Purpose: Compare GF Element with unity element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pResult
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the finite field element.
+// pResult Pointer to the result of the comparison
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpIsUnityElement,(const IppsGFpElement* pA,
+ int* pResult,
+ const IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pResult, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
+ int basicElmLen = GFP_FELEN(pBasicGFE);
+ BNU_CHUNK_T* pUnity = GFP_MNT_R(pBasicGFE);
+
+ int elmLen = GFP_FELEN(pGFE);
+ int flag;
+
+ FIX_BNU(pUnity, basicElmLen);
+ FIX_BNU(GFPE_DATA(pA), elmLen);
+
+ flag = (basicElmLen==elmLen) && (0 == cpGFpElementCmp(GFPE_DATA(pA), pUnity, elmLen));
+ *pResult = (1==flag)? IPP_IS_EQ : IPP_IS_NE;
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpiszeroelem.c b/ext/ipp/sources/ippcp/pcpgfpiszeroelem.c
new file mode 100644
index 0000000..c60a839
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpiszeroelem.c
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpIsZeroElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpIsZeroElement
+//
+// Purpose: Compare GF Element with zero element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pResult
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the finite field element.
+// pResult Pointer to the result of the comparison
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpIsZeroElement,(const IppsGFpElement* pA,
+ int* pResult,
+ const IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pResult, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ {
+ int flag = GFP_IS_ZERO(GFPE_DATA(pA), GFP_FELEN(pGFE));
+ *pResult = (1==flag)? IPP_IS_EQ : IPP_IS_NE;
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpmethod.h b/ext/ipp/sources/ippcp/pcpgfpmethod.h
new file mode 100644
index 0000000..561b773
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives
+// Internal GF(p) basic Definitions & Function Prototypes
+//
+*/
+#if !defined(_CP_GFP_METHOD_H)
+#define _CP_GFP_METHOD_H
+
+#include "owncp.h"
+
+#include "pcpbnuimpl.h"
+#include "gsmodmethod.h"
+
+/* modulus ID */
+typedef enum {
+ cpID_Prime = 0x1000,
+ cpID_PrimeP192r1 = cpID_Prime+6,
+ cpID_PrimeP224r1 = cpID_Prime+7,
+ cpID_PrimeP256r1 = cpID_Prime+8,
+ cpID_PrimeP384r1 = cpID_Prime+9,
+ cpID_PrimeP521r1 = cpID_Prime+10,
+ cpID_PrimeTPM_SM2 = cpID_Prime+11,
+ cpID_PrimeTPM_BN = cpID_Prime+12,
+
+ cpID_Poly = 0x10000000, /* id=0x10000000: general polynomial */
+ cpID_Binom = 0x01000000, /* id=0x11000000: x^d+a */
+
+ cpID_Binom2_epid20 = cpID_Binom|0x220000, /* 0x11220000 */
+ cpID_Binom3_epid20 = cpID_Binom|0x230000 /* 0x11230000 */
+
+} cpModulusID;
+
+typedef struct _cpGFpMethod {
+ cpModulusID modulusID;
+ int modulusBitDeg;
+ const BNU_CHUNK_T* modulus;
+ const gsModMethod* arith;
+} cpGFpMethod;
+
+/* common GF arith methods */
+#define gsArithGFp OWNAPI(gsArithGFp)
+gsModMethod* gsArithGFp(void);
+
+#endif /* _CP_GFP_METHOD_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_192r1.c b/ext/ipp/sources/ippcp/pcpgfpmethod_192r1.c
index 3fb5861..b558977 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_192r1.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_192r1.c
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -28,28 +52,56 @@
#include "pcpgfpmethod.h"
#include "pcpecprime.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
/* arithmetic over P-192r1 NIST modulus */
+#define p192r1_add OWNAPI(p192r1_add)
BNU_CHUNK_T* p192r1_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+
+#define p192r1_sub OWNAPI(p192r1_sub)
BNU_CHUNK_T* p192r1_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+
+#define p192r1_neg OWNAPI(p192r1_neg)
BNU_CHUNK_T* p192r1_neg(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_div_by_2 OWNAPI(p192r1_div_by_2)
BNU_CHUNK_T* p192r1_div_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_mul_by_2 OWNAPI(p192r1_mul_by_2)
BNU_CHUNK_T* p192r1_mul_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_mul_by_3 OWNAPI(p192r1_mul_by_3)
BNU_CHUNK_T* p192r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
#if(_IPP_ARCH ==_IPP_ARCH_EM64T)
+#define p192r1_mul_montl OWNAPI(p192r1_mul_montl)
BNU_CHUNK_T* p192r1_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+
+#define p192r1_mul_montx OWNAPI(p192r1_mul_montx)
BNU_CHUNK_T* p192r1_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+
+#define p192r1_sqr_montl OWNAPI(p192r1_sqr_montl)
BNU_CHUNK_T* p192r1_sqr_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_sqr_montx OWNAPI(p192r1_sqr_montx)
BNU_CHUNK_T* p192r1_sqr_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_to_mont OWNAPI(p192r1_to_mont)
BNU_CHUNK_T* p192r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_mont_back OWNAPI(p192r1_mont_back)
BNU_CHUNK_T* p192r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
#if(_IPP_ARCH ==_IPP_ARCH_IA32)
+#define p192r1_mul_mont_slm OWNAPI(p192r1_mul_mont_slm)
BNU_CHUNK_T* p192r1_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+
+#define p192r1_sqr_mont_slm OWNAPI(p192r1_sqr_mont_slm)
BNU_CHUNK_T* p192r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p192r1_mred OWNAPI(p192r1_mred)
BNU_CHUNK_T* p192r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
#endif
@@ -64,7 +116,7 @@ BNU_CHUNK_T* p192r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
static BNU_CHUNK_T* p192r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpMulAdc_BNU_school(product, pA,LEN_P192, pB,LEN_P192);
p192r1_mred(pR, product);
@@ -76,7 +128,7 @@ static BNU_CHUNK_T* p192r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, con
static BNU_CHUNK_T* p192r1_sqr_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpSqrAdc_BNU_school(product, pA,LEN_P192);
p192r1_mred(pR, product);
@@ -138,7 +190,7 @@ static gsModMethod* gsArithGF_p192r1(void)
};
#if(_IPP_ARCH==_IPP_ARCH_EM64T) && ((_ADCOX_NI_ENABLING_==_FEATURE_ON_) || (_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_))
- if(IsFeatureEnabled(ADCOX_ENABLED)) {
+ if(IsFeatureEnabled(ippCPUID_ADCOX)) {
m.mul = p192r1_mul_montx;
m.sqr = p192r1_sqr_montx;
}
@@ -157,6 +209,15 @@ static gsModMethod* gsArithGF_p192r1(void)
}
#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
+/*F*
+// Name: ippsGFpMethod_p192r1
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q = 2^192 - 2^64 - 1
+*F*/
IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p192r1, (void) )
{
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_224r1.c b/ext/ipp/sources/ippcp/pcpgfpmethod_224r1.c
index 72ce5ce..61a0202 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_224r1.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_224r1.c
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -28,18 +52,35 @@
#include "pcpgfpmethod.h"
#include "pcpecprime.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
/* arithmetic over P-224r1 NIST modulus */
-BNU_CHUNK_T* p224r1_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* p224r1_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* p224r1_neg(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
+#define p224r1_add OWNAPI(p224r1_add)
+#define p224r1_sub OWNAPI(p224r1_sub)
+#define p224r1_neg OWNAPI(p224r1_neg)
+#define p224r1_div_by_2 OWNAPI(p224r1_div_by_2)
+#define p224r1_mul_by_2 OWNAPI(p224r1_mul_by_2)
+#define p224r1_mul_by_3 OWNAPI(p224r1_mul_by_3)
+
+BNU_CHUNK_T* p224r1_add (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+BNU_CHUNK_T* p224r1_sub (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
+BNU_CHUNK_T* p224r1_neg (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_div_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_mul_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
#if(_IPP_ARCH ==_IPP_ARCH_EM64T)
+
+#define p224r1_mul_montl OWNAPI(p224r1_mul_montl)
+#define p224r1_mul_montx OWNAPI(p224r1_mul_montx)
+#define p224r1_sqr_montl OWNAPI(p224r1_sqr_montl)
+#define p224r1_sqr_montx OWNAPI(p224r1_sqr_montx)
+#define p224r1_to_mont OWNAPI(p224r1_to_mont)
+#define p224r1_mont_back OWNAPI(p224r1_mont_back)
+
BNU_CHUNK_T* p224r1_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_sqr_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
@@ -47,7 +88,13 @@ BNU_CHUNK_T* p224r1_sqr_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine*
BNU_CHUNK_T* p224r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
+
#if(_IPP_ARCH ==_IPP_ARCH_IA32)
+
+#define p224r1_mul_mont_slm OWNAPI(p224r1_mul_mont_slm)
+#define p224r1_sqr_mont_slm OWNAPI(p224r1_sqr_mont_slm)
+#define p224r1_mred OWNAPI(p224r1_mred)
+
BNU_CHUNK_T* p224r1_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p224r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
@@ -64,7 +111,7 @@ BNU_CHUNK_T* p224r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
static BNU_CHUNK_T* p224r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpMulAdc_BNU_school(product, pA,LEN_P224, pB,LEN_P224);
p224r1_mred(pR, product);
@@ -76,7 +123,7 @@ static BNU_CHUNK_T* p224r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, con
static BNU_CHUNK_T* p224r1_sqr_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpSqrAdc_BNU_school(product, pA,LEN_P224);
p224r1_mred(pR, product);
@@ -138,7 +185,7 @@ static gsModMethod* gsArithGF_p224r1(void)
};
#if(_IPP_ARCH==_IPP_ARCH_EM64T) && ((_ADCOX_NI_ENABLING_==_FEATURE_ON_) || (_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_))
- if(IsFeatureEnabled(ADCOX_ENABLED)) {
+ if(IsFeatureEnabled(ippCPUID_ADCOX)) {
m.mul = p224r1_mul_montx;
m.sqr = p224r1_sqr_montx;
}
@@ -157,6 +204,16 @@ static gsModMethod* gsArithGF_p224r1(void)
}
#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
+/*F*
+// Name: ippsGFpMethod_p224r1
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q = 2^224 - 2^96 - 1
+*F*/
+
IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p224r1, (void) )
{
static IppsGFpMethod method = {
diff --git a/ext/ipp/sources/ippcp/pcpgfpmethod_256.c b/ext/ipp/sources/ippcp/pcpgfpmethod_256.c
new file mode 100644
index 0000000..2f5acce
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_256.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p) methods
+//
+*/
+#include "pcpgfpmethod_256.h"
+
+/*F*
+// Name: ippsGFpMethod_p256
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). Arbitrary 256 bit modulus.
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Prime,
+ 256,
+ NULL,
+ NULL
+ };
+
+ #if(_IPP32E >= _IPP32E_M7)
+ method.arith = gsArithGF_p256();
+ #else
+ method.arith = gsArithGFp();
+ #endif
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_256.c b/ext/ipp/sources/ippcp/pcpgfpmethod_256.h
index db19629..2861893 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_256.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_256.h
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -27,9 +51,19 @@
#include "pcpgfpmethod.h"
#include "pcpecprime.h"
+#if !defined(_PCP_GFPMETHOD_256_H_)
+#define _PCP_GFPMETHOD_256_H_
+
#if(_IPP32E >= _IPP32E_M7)
/* arithmetic over arbitrary 256r-bit modulus */
+#define gf256_add OWNAPI(gf256_add)
+#define gf256_sub OWNAPI(gf256_sub)
+#define gf256_neg OWNAPI(gf256_neg)
+#define gf256_mulm OWNAPI(gf256_mulm)
+#define gf256_sqrm OWNAPI(gf256_sqrm)
+#define gf256_div2 OWNAPI(gf256_div2)
+
BNU_CHUNK_T* gf256_add(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pModulus);
BNU_CHUNK_T* gf256_sub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pModulus);
BNU_CHUNK_T* gf256_neg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pModulus);
@@ -115,40 +149,7 @@ static gsModMethod* gsArithGF_p256(void)
}
#endif /* _IPP32E >= _IPP32E_M7 */
-
-IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Prime,
- 256,
- NULL,
- NULL
- };
-
- #if(_IPP32E >= _IPP32E_M7)
- method.arith = gsArithGF_p256();
- #else
- method.arith = gsArithGFp();
- #endif
- return &method;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256bn, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Prime,
- 256,
- tpmBN_p256p_p,
- NULL
- };
-
- #if(_IPP32E >= _IPP32E_M7)
- method.arith = gsArithGF_p256();
- #else
- method.arith = gsArithGFp();
- #endif
- return &method;
-}
-
#undef LEN_P256
#undef OPERAND_BITSIZE
+
+#endif /* #if !defined(_PCP_GFPMETHOD_256_H_) */
diff --git a/ext/ipp/sources/ippcp/pcpgfpmethod_256bn.c b/ext/ipp/sources/ippcp/pcpgfpmethod_256bn.c
new file mode 100644
index 0000000..bfc4953
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_256bn.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p) methods
+//
+*/
+
+#include "pcpgfpmethod_256.h"
+
+/*F*
+// Name: ippsGFpMethod_p256bn
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q =
+// 0xFFFFFFFFFFFCF0CD46E5F25EEE71A49F0CDC65FB12980A82D3292DDBAED33013
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256bn, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Prime,
+ 256,
+ tpmBN_p256p_p,
+ NULL
+ };
+
+ #if(_IPP32E >= _IPP32E_M7)
+ method.arith = gsArithGF_p256();
+ #else
+ method.arith = gsArithGFp();
+ #endif
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_256r1.c b/ext/ipp/sources/ippcp/pcpgfpmethod_256r1.c
index 3e51fea..cc0c55b 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_256r1.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_256r1.c
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -28,10 +52,17 @@
#include "pcpgfpmethod.h"
#include "pcpecprime.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
+#define p256r1_add OWNAPI(p256r1_add)
+#define p256r1_sub OWNAPI(p256r1_sub)
+#define p256r1_neg OWNAPI(p256r1_neg)
+#define p256r1_div_by_2 OWNAPI(p256r1_div_by_2)
+#define p256r1_mul_by_2 OWNAPI(p256r1_mul_by_2)
+#define p256r1_mul_by_3 OWNAPI(p256r1_mul_by_3)
+
/* arithmetic over P-256r1 NIST modulus */
BNU_CHUNK_T* p256r1_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
@@ -39,7 +70,16 @@ BNU_CHUNK_T* p256r1_neg(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_div_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_mul_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
#if(_IPP_ARCH ==_IPP_ARCH_EM64T)
+
+#define p256r1_mul_montl OWNAPI(p256r1_mul_montl)
+#define p256r1_mul_montx OWNAPI(p256r1_mul_montx)
+#define p256r1_sqr_montl OWNAPI(p256r1_sqr_montl)
+#define p256r1_sqr_montx OWNAPI(p256r1_sqr_montx)
+#define p256r1_to_mont OWNAPI(p256r1_to_mont)
+#define p256r1_mont_back OWNAPI(p256r1_mont_back)
+
BNU_CHUNK_T* p256r1_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_sqr_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
@@ -48,6 +88,10 @@ BNU_CHUNK_T* p256r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine*
BNU_CHUNK_T* p256r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
#if(_IPP_ARCH ==_IPP_ARCH_IA32)
+#define p256r1_mul_mont_slm OWNAPI(p256r1_mul_mont_slm)
+#define p256r1_sqr_mont_slm OWNAPI(p256r1_sqr_mont_slm)
+#define p256r1_mred OWNAPI(p256r1_mred)
+
BNU_CHUNK_T* p256r1_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p256r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
@@ -64,7 +108,7 @@ BNU_CHUNK_T* p256r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
static BNU_CHUNK_T* p256r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpMulAdc_BNU_school(product, pA,LEN_P256, pB,LEN_P256);
p256r1_mred(pR, product);
@@ -76,7 +120,7 @@ static BNU_CHUNK_T* p256r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, con
static BNU_CHUNK_T* p256r1_sqr_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpSqrAdc_BNU_school(product, pA,LEN_P256);
p256r1_mred(pR, product);
@@ -138,7 +182,7 @@ static gsModMethod* gsArithGF_p256r1(void)
};
#if(_IPP_ARCH==_IPP_ARCH_EM64T) && ((_ADCOX_NI_ENABLING_==_FEATURE_ON_) || (_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_))
- if(IsFeatureEnabled(ADCOX_ENABLED)) {
+ if(IsFeatureEnabled(ippCPUID_ADCOX)) {
m.mul = p256r1_mul_montx;
m.sqr = p256r1_sqr_montx;
}
@@ -157,6 +201,16 @@ static gsModMethod* gsArithGF_p256r1(void)
}
#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
+/*F*
+// Name: ippsGFpMethod_p256r1
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q = 2^256 - 2^224 + 2^192 + 2^96 - 1
+*F*/
+
IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256r1, (void) )
{
static IppsGFpMethod method = {
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_384r1.c b/ext/ipp/sources/ippcp/pcpgfpmethod_384r1.c
index 8caa825..66360e0 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_384r1.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_384r1.c
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -29,10 +53,17 @@
#include "pcpbnuarith.h"
#include "pcpecprime.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
+#define p384r1_add OWNAPI(p384r1_add)
+#define p384r1_sub OWNAPI(p384r1_sub)
+#define p384r1_neg OWNAPI(p384r1_neg)
+#define p384r1_div_by_2 OWNAPI(p384r1_div_by_2)
+#define p384r1_mul_by_2 OWNAPI(p384r1_mul_by_2)
+#define p384r1_mul_by_3 OWNAPI(p384r1_mul_by_3)
+
/* arithmetic over P-384r1 NIST modulus */
BNU_CHUNK_T* p384r1_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p384r1_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
@@ -48,8 +79,15 @@ BNU_CHUNK_T* p384r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine*
//BNU_CHUNK_T* p384r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
//BNU_CHUNK_T* p384r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
+
+#define p384r1_mred OWNAPI(p384r1_mred)
BNU_CHUNK_T* p384r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
+
#if(_IPP_ARCH ==_IPP_ARCH_IA32)
+
+#define p384r1_mul_mont_slm OWNAPI(p384r1_mul_mont_slm)
+#define p384r1_sqr_mont_slm OWNAPI(p384r1_sqr_mont_slm)
+
BNU_CHUNK_T* p384r1_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p384r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
@@ -64,7 +102,7 @@ BNU_CHUNK_T* p384r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngin
static BNU_CHUNK_T* p384r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpMul_BNU_school(product, pA,LEN_P384, pB,LEN_P384);
p384r1_mred(pR, product);
@@ -160,6 +198,16 @@ static gsModMethod* gsArithGF_p384r1(void)
}
#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
+/*F*
+// Name: ippsGFpMethod_p384r1
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q = 2^384 - 2^128 - 2^96 + 2^32 - 1
+*F*/
+
IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p384r1, (void) )
{
static IppsGFpMethod method = {
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_521r1.c b/ext/ipp/sources/ippcp/pcpgfpmethod_521r1.c
index 789be03..30cadcc 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_521r1.c
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_521r1.c
@@ -1,21 +1,45 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
// GF(p) methods
//
*/
@@ -29,10 +53,17 @@
#include "pcpbnuarith.h"
#include "pcpecprime.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
+#define p521r1_add OWNAPI(p521r1_add)
+#define p521r1_sub OWNAPI(p521r1_sub)
+#define p521r1_neg OWNAPI(p521r1_neg)
+#define p521r1_div_by_2 OWNAPI(p521r1_div_by_2)
+#define p521r1_mul_by_2 OWNAPI(p521r1_mul_by_2)
+#define p521r1_mul_by_3 OWNAPI(p521r1_mul_by_3)
+
/* arithmetic over P-521r1 NIST modulus */
BNU_CHUNK_T* p521r1_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p521r1_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
@@ -40,7 +71,9 @@ BNU_CHUNK_T* p521r1_neg(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p521r1_div_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p521r1_mul_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
BNU_CHUNK_T* p521r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
+
#if(_IPP_ARCH ==_IPP_ARCH_EM64T)
+
//BNU_CHUNK_T* p521r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
//BNU_CHUNK_T* p521r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
//BNU_CHUNK_T* p521r1_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
@@ -48,8 +81,14 @@ BNU_CHUNK_T* p521r1_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine*
//BNU_CHUNK_T* p521r1_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
//BNU_CHUNK_T* p521r1_sqr_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
+
+#define p521r1_mred OWNAPI(p521r1_mred)
BNU_CHUNK_T* p521r1_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
+
#if(_IPP_ARCH ==_IPP_ARCH_IA32)
+#define p521r1_mul_mont_slm OWNAPI(p521r1_mul_mont_slm)
+#define p521r1_sqr_mont_slm OWNAPI(p521r1_sqr_mont_slm)
+
BNU_CHUNK_T* p521r1_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
BNU_CHUNK_T* p521r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
#endif
@@ -64,7 +103,7 @@ BNU_CHUNK_T* p521r1_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngin
static BNU_CHUNK_T* p521r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpMul_BNU_school(product, pA,LEN_P521, pB,LEN_P521);
p521r1_mred(pR, product);
@@ -76,7 +115,7 @@ static BNU_CHUNK_T* p521r1_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, con
static BNU_CHUNK_T* p521r1_sqr_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
{
BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
+ //tbcd: temporary excluded: assert(NULL!=product);
cpSqr_BNU_school(product, pA,LEN_P521);
p521r1_mred(pR, product);
@@ -167,6 +206,16 @@ static gsModMethod* gsArithGF_p521r1(void)
}
#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
+/*F*
+// Name: ippsGFpMethod_p521r1
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). q = 2^521 - 1
+*F*/
+
IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p521r1, (void) )
{
static IppsGFpMethod method = {
diff --git a/ext/ipp/sources/ippcp/pcpgfpmethod_com.c b/ext/ipp/sources/ippcp/pcpgfpmethod_com.c
new file mode 100644
index 0000000..2e0d840
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmethod_com.c
@@ -0,0 +1,70 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpmethod.h"
+
+/*F*
+// Name: ippsGFpMethod_pArb
+//
+// Purpose: Returns a reference to an implementation of
+// arithmetic operations over GF(q).
+//
+// Returns: Pointer to a structure containing an implementation of arithmetic
+// operations over GF(q). Arbitrary modulus q.
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpMethod_pArb, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Prime,
+ 0,
+ NULL,
+ NULL
+ };
+ method.arith = gsArithGFp();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpmul.c b/ext/ipp/sources/ippcp/pcpgfpmul.c
new file mode 100644
index 0000000..86985e5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmul.c
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpMul()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpMul
+//
+// Purpose: Multiply of GF elements
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpMul,(const IppsGFpElement* pA, const IppsGFpElement* pB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ GFP_METHOD(pGFE)->mul(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pB),pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpmulexp.c b/ext/ipp/sources/ippcp/pcpgfpmulexp.c
new file mode 100644
index 0000000..6173f8f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmulexp.c
@@ -0,0 +1,158 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpMultiExp()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: ippsGFpMultiExp
+//
+// Purpose: Multiplies exponents of GF elements
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == ppElmA
+// NULL == pR
+// NULL == ppE
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid ppElmA[i]->idCtx
+// invalid pR->idCtx
+// invalid ppE[i]->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr 1>nItems
+// nItems>6
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// ppElmA Pointer to the array of contexts of the finite field elements representing the base of the exponentiation.
+// ppE Pointer to the array of the Big Number contexts storing the exponents.
+// nItems Number of exponents.
+// pR Pointer to the context of the resulting element of the finite field.
+// pGFp Pointer to the context of the finite field.
+// pScratchBuffer Pointer to the scratch buffer.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems,
+ IppsGFpElement* pR, IppsGFpState* pGFp,
+ Ipp8u* pScratchBuffer))
+{
+ IPP_BAD_PTR2_RET(ppElmA, ppE);
+
+ if(nItems==1)
+ return ippsGFpExp(ppElmA[0], ppE[0], pR, pGFp, pScratchBuffer);
+
+ else {
+ /* test number of exponents */
+ IPP_BADARG_RET(1>nItems || nItems>IPP_MAX_EXPONENT_NUM, ippStsBadArgErr);
+
+ IPP_BAD_PTR2_RET(pR, pGFp);
+
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ int n;
+
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pR)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ /* test all ppElmA[] and ppE[] pairs */
+ for(n=0; n<nItems; n++) {
+ const IppsGFpElement* pElmA = ppElmA[n];
+ const IppsBigNumState* pE = ppE[n];
+ IPP_BAD_PTR2_RET(pElmA, pE);
+
+ IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
+ pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
+ IPP_BADARG_RET( !BN_VALID_ID(pE), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ }
+
+ if(NULL==pScratchBuffer) {
+ mod_mul mulF = GFP_METHOD(pGFE)->mul;
+
+ BNU_CHUNK_T* pTmpR = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(NULL!=pTmpR);
+
+ cpGFpxExp(GFPE_DATA(pR), GFPE_DATA(ppElmA[0]), BN_NUMBER(ppE[0]), BN_SIZE(ppE[0]), pGFE, 0);
+ for(n=1; n<nItems; n++) {
+ cpGFpxExp(pTmpR, GFPE_DATA(ppElmA[n]), BN_NUMBER(ppE[n]), BN_SIZE(ppE[n]), pGFE, 0);
+ mulF(GFPE_DATA(pR), GFPE_DATA(pR), pTmpR, pGFE);
+ }
+
+ cpGFpReleasePool(1, pGFE);
+ }
+
+ else {
+ const BNU_CHUNK_T* ppAdata[IPP_MAX_EXPONENT_NUM];
+ const BNU_CHUNK_T* ppEdata[IPP_MAX_EXPONENT_NUM];
+ int nsEdataLen[IPP_MAX_EXPONENT_NUM];
+ for(n=0; n<nItems; n++) {
+ ppAdata[n] = GFPE_DATA(ppElmA[n]);
+ ppEdata[n] = BN_NUMBER(ppE[n]);
+ nsEdataLen[n] = BN_SIZE(ppE[n]);
+ }
+ cpGFpxMultiExp(GFPE_DATA(pR), ppAdata, ppEdata, nsEdataLen, nItems, pGFE, pScratchBuffer);
+ }
+
+ return ippStsNoErr;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpmulpe.c b/ext/ipp/sources/ippcp/pcpgfpmulpe.c
new file mode 100644
index 0000000..ac86d4c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpmulpe.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpMul_PE()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpMul_PE
+//
+// Purpose: Multiply of GF element and parent GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pParentB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pParentB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr pGFp does not specify prime field
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pParentB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpMul_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pParentB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pParentB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( (GFPE_ROOM(pParentB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
+
+ cpGFpxMul_GFE(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pParentB), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpneg.c b/ext/ipp/sources/ippcp/pcpgfpneg.c
new file mode 100644
index 0000000..d486ea3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpneg.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpNeg()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpNeg
+//
+// Purpose: Additive inverse GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the source finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpNeg,(const IppsGFpElement* pA,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ GFP_METHOD(pGFE)->neg(GFPE_DATA(pR), GFPE_DATA(pA), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelem.c b/ext/ipp/sources/ippcp/pcpgfpsetelem.c
new file mode 100644
index 0000000..500324c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelem.c
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElement()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: ippsGFpSetElement
+//
+// Purpose: Set GF Element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pR
+// NULL == pA && lenA>0
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pR->idCtx
+//
+// ippStsSizeErr pA && !(0<=lenA && lenA<GFP_FELEN32())
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+// BNU representation of pA[i]..pA[i+GFP_FELEN32()-1] >= modulus
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA pointer to the data representation Finite Field element
+// lenA length of Finite Field data representation array
+// pR pointer to Finite Field Element context
+// pGFp pointer to Finite Field context
+*F*/
+IPPFUN(IppStatus, ippsGFpSetElement,(const Ipp32u* pA, int lenA, IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR2_RET(pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( !pA && (0<lenA), ippStsNullPtrErr);
+ IPP_BADARG_RET( pA && !(0<=lenA && lenA<=GFP_FELEN32(GFP_PMA(pGFp))), ippStsSizeErr );
+ IPP_BADARG_RET( GFPE_ROOM(pR)!=GFP_FELEN(GFP_PMA(pGFp)), ippStsOutOfRangeErr );
+
+ {
+ IppStatus sts = ippStsNoErr;
+
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ int elemLen = GFP_FELEN(pGFE);
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
+ //tbcd: temporary excluded: assert(NULL!=pTmp);
+
+ ZEXPAND_BNU(pTmp, 0, elemLen);
+ if(pA && lenA)
+ cpGFpxCopyToChunk(pTmp, pA, lenA, pGFE);
+
+ if(!cpGFpxSet(GFPE_DATA(pR), pTmp, elemLen, pGFE))
+ sts = ippStsOutOfRangeErr;
+
+ cpGFpReleasePool(1, pGFE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelemhash.c b/ext/ipp/sources/ippcp/pcpgfpsetelemhash.c
new file mode 100644
index 0000000..4f6e412
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelemhash.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElementHash()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpSetElementHash
+//
+// Purpose: Set GF Element Hash of the Message
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pElm
+// NULL == pMsg if msgLen>0
+//
+// ippStsNotSupportedModeErr hashID is not supported
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pElm->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr !GFP_IS_BASIC(pGFE)
+//
+// ippStsLengthErr msgLen<0
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pMsg pointer to the message is being hashed
+// msgLen length of the message above
+// pElm pointer to Finite Field Element context
+// pGFp pointer to Finite Field context
+// hashID applied hash algorithm ID
+*F*/
+IPPFUN(IppStatus, ippsGFpSetElementHash,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGFp, IppHashAlgId hashID))
+{
+ /* get algorithm id */
+ hashID = cpValidHashAlg(hashID);
+ IPP_BADARG_RET(ippHashAlg_Unknown==hashID, ippStsNotSupportedModeErr);
+
+ /* test message length and pointer */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ IPP_BAD_PTR2_RET(pElm, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr);
+ IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr);
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ {
+ Ipp8u md[MAX_HASH_SIZE];
+ BNU_CHUNK_T hashVal[(MAX_HASH_SIZE*8)/BITSIZE(BNU_CHUNK_T)+1]; /* +1 to meet cpMod_BNU() implementtaion specific */
+ IppStatus sts = ippsHashMessage(pMsg, msgLen, md, hashID);
+
+ if(ippStsNoErr==sts) {
+ int elemLen = GFP_FELEN(pGFE);
+ int hashLen = cpHashAlgAttr[hashID].hashSize;
+ int hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
+ hashValLen = cpMod_BNU(hashVal, hashValLen, GFP_MODULUS(pGFE), elemLen);
+ cpGFpSet(GFPE_DATA(pElm), hashVal, hashValLen, pGFE);
+ }
+
+ return sts;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelemhashrmf.c b/ext/ipp/sources/ippcp/pcpgfpsetelemhashrmf.c
new file mode 100644
index 0000000..78b6935
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelemhashrmf.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElementHash_rmf
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpSetElementHash_rmf
+//
+// Purpose: Set GF Element Hash of the Message
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pElm
+// NULL == pMsg if msgLen>0
+// NULL = pMethod
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pElm->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr !GFP_IS_BASIC(pGFE)
+//
+// ippStsLengthErr msgLen<0
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pMsg pointer to the message is being hashed
+// msgLen length of the message above
+// pElm pointer to Finite Field Element context
+// pGFp pointer to Finite Field context
+// pMethod pointer to hash method
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSetElementHash_rmf,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGFp, const IppsHashMethod* pMethod))
+{
+ /* test method pointer */
+ IPP_BAD_PTR1_RET(pMethod);
+
+ /* test message length and pointer */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ IPP_BAD_PTR2_RET(pElm, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr);
+ IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr);
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr);
+ IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+
+ {
+ Ipp8u md[MAX_HASH_SIZE];
+ BNU_CHUNK_T hashVal[(MAX_HASH_SIZE*8)/BITSIZE(BNU_CHUNK_T)+1]; /* +1 to meet cpMod_BNU() implementtaion specific */
+ IppStatus sts = ippsHashMessage_rmf(pMsg, msgLen, md, pMethod);
+
+ if(ippStsNoErr==sts) {
+ int elemLen = GFP_FELEN(pGFE);
+ int hashLen = pMethod->hashLen;
+ int hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
+ hashValLen = cpMod_BNU(hashVal, hashValLen, GFP_MODULUS(pGFE), elemLen);
+ cpGFpSet(GFPE_DATA(pElm), hashVal, hashValLen, pGFE);
+ }
+
+ return sts;
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelemoctstr.c b/ext/ipp/sources/ippcp/pcpgfpsetelemoctstr.c
new file mode 100644
index 0000000..770c059
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelemoctstr.c
@@ -0,0 +1,120 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElementOctString()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpSetElementOctString
+//
+// Purpose: Set GF Element from the input octet string
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pR
+// NULL == pStr && strSize>0
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pR->idCtx
+//
+// ippStsSizeErr !(0<strSize && strSize<=(int)(GFP_FELEN32()*sizeof(Ipp32u)))
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+// BNU representation of pStr[] >= modulus
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pStr Pointer to the octet string
+// strSize Size of the octet string buffer in bytes.
+// pR pointer to Finite Field Element context
+// pGFp pointer to Finite Field context
+*F*/
+IPPFUN(IppStatus, ippsGFpSetElementOctString,(const Ipp8u* pStr, int strSize, IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR2_RET(pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( (!pStr && 0<strSize), ippStsNullPtrErr);
+ IPP_BADARG_RET(!(0<strSize && strSize<=(int)(GFP_FELEN32(GFP_PMA(pGFp))*sizeof(Ipp32u))), ippStsSizeErr );
+
+ IPP_BADARG_RET( GFPE_ROOM(pR)!=GFP_FELEN(GFP_PMA(pGFp)), ippStsOutOfRangeErr);
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFE);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGFE),GFP_FELEN(pBasicGFE)));
+
+ BNU_CHUNK_T* pDataElm = GFPE_DATA(pR);
+
+ int deg, error;
+ /* set element to zero */
+ cpGFpElementPadd(pDataElm, GFP_FELEN(pGFE), 0);
+
+ /* convert oct string to element (from low to high) */
+ for(deg=0, error=0; deg<basicDeg && !error; deg++) {
+ int size = IPP_MIN(strSize, basicSize);
+ error = NULL == cpGFpSetOctString(pDataElm, pStr, size, pBasicGFE);
+
+ pDataElm += basicElemLen;
+ strSize -= size;
+ pStr += size;
+ }
+
+ return error? ippStsOutOfRangeErr : ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelemrand.c b/ext/ipp/sources/ippcp/pcpgfpsetelemrand.c
new file mode 100644
index 0000000..2142c30
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelemrand.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElementRandom()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpSetElementRandom
+//
+// Purpose: Set GF Element Random
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pR
+// NULL == rndFunc
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsErr internal error caused by call of rndFunc()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pR Pointer to the context of the finite field element.
+// pGFp Pointer to the context of the finite field.
+// rndFunc Pseudorandom number generator.
+// pRndParam Pointer to the context of the pseudorandom number generator.
+*F*/
+IPPFUN(IppStatus, ippsGFpSetElementRandom,(IppsGFpElement* pR, IppsGFpState* pGFp,
+ IppBitSupplier rndFunc, void* pRndParam))
+{
+ IPP_BAD_PTR3_RET(pR, pGFp, rndFunc);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFPE_ROOM(pR)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
+ return cpGFpxRand(GFPE_DATA(pR), pGFE, rndFunc, pRndParam)? ippStsNoErr : ippStsErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsetelemreg.c b/ext/ipp/sources/ippcp/pcpgfpsetelemreg.c
new file mode 100644
index 0000000..4899ce4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsetelemreg.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSetElementRegular()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpSetElement
+//
+// Purpose: Set GF Element from the input Big Number
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pR
+// NULL == pBN
+//
+// ippStsContextMatchErr invalid pBN->idCtx
+//
+// ippStsOutOfRangeErr BN is not positive
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pBN pointer to the Big Number context
+// pR pointer to Finite Field Element context
+// pGFp pointer to Finite Field context
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSetElementRegular,(const IppsBigNumState* pBN, IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR1_RET(pBN);
+ pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
+ IPP_BADARG_RET( !BN_VALID_ID(pBN), ippStsContextMatchErr );
+ IPP_BADARG_RET( !BN_POSITIVE(pBN), ippStsOutOfRangeErr);
+
+ return ippsGFpSetElement((Ipp32u*)BN_NUMBER(pBN), BITS2WORD32_SIZE( BITSIZE_BNU(BN_NUMBER((pBN)),BN_SIZE((pBN)))), pR, pGFp);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsqr.c b/ext/ipp/sources/ippcp/pcpgfpsqr.c
new file mode 100644
index 0000000..de5863c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsqr.c
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSqr()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsGFpSqr
+//
+// Purpose: Square of GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the source finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSqr,(const IppsGFpElement* pA,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ GFP_METHOD(pGFE)->sqr(GFPE_DATA(pR), GFPE_DATA(pA), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsqrt.c b/ext/ipp/sources/ippcp/pcpgfpsqrt.c
new file mode 100644
index 0000000..6d44b34
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsqrt.c
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSqrt()
+//
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsGFpSqrt
+//
+// Purpose: Square root of GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsDivByZeroErr pA is zero
+//
+// ippStsBadArgErr pGFp is not prime
+//
+// ippStsQuadraticNonResidueErr pA is a square non-residue
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the source finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSqrt,(const IppsGFpElement* pA,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR3_RET(pA, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr )
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ return cpGFpSqrt(GFPE_DATA(pR), GFPE_DATA(pA), pGFE)? ippStsNoErr : ippStsQuadraticNonResidueErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpstuff.h b/ext/ipp/sources/ippcp/pcpgfpstuff.h
index fac2215..1b751a6 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpstuff.h
+++ b/ext/ipp/sources/ippcp/pcpgfpstuff.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Purpose:
@@ -26,7 +50,6 @@
#define _PCP_GFP_H_
#include "owncp.h"
-//#include "pcpbn.h"
#include "pcpgfpmethod.h"
#include "pcpmontgomery.h"
@@ -118,17 +141,10 @@ __INLINE int cpGFpElementCmp(const BNU_CHUNK_T* pE, const BNU_CHUNK_T* pX, int n
return pE[nsE-1]==pX[nsE-1]? 0 : pE[nsE-1]>pX[nsE-1]? 1:-1;
}
-#define CP_CT_MSB(a) ((a)>>((sizeof((a))*8 -1)))
-#define CP_CT_IS_ZERO(a) CP_CT_MSB(~(a) & ((a)-1))
-
__INLINE int cpGFpElementIsEquChunk(const BNU_CHUNK_T* pE, int nsE, BNU_CHUNK_T x)
{
- int i;
- BNU_CHUNK_T accum = pE[0] ^ x;
- for (i = 1; i < nsE; i++) {
- accum |= pE[i];
- }
- return CP_CT_IS_ZERO(accum); /*(accum == 0); */
+ int isEqu = (pE[0] == x);
+ return isEqu && (1==cpGFpElementLen(pE, nsE));
}
__INLINE BNU_CHUNK_T* cpGFpElementSetChunk(BNU_CHUNK_T* pR, int nsR, BNU_CHUNK_T x)
@@ -136,6 +152,36 @@ __INLINE BNU_CHUNK_T* cpGFpElementSetChunk(BNU_CHUNK_T* pR, int nsR, BNU_CHUNK_T
return cpGFpElementCopyPadd(pR, nsR, &x, 1);
}
+__INLINE BNU_CHUNK_T* cpGFpAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->add(pR, pA, pB, pGFE);
+}
+
+__INLINE BNU_CHUNK_T* cpGFpSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->sub(pR, pA, pB, pGFE);
+}
+
+__INLINE BNU_CHUNK_T* cpGFpNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->neg(pR, pA, pGFE);
+}
+
+__INLINE BNU_CHUNK_T* cpGFpMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->mul(pR, pA, pB, pGFE);
+}
+
+__INLINE BNU_CHUNK_T* cpGFpSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->sqr(pR, pA, pGFE);
+}
+
+__INLINE BNU_CHUNK_T* cpGFpHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
+{
+ return GFP_METHOD(pGFE)->div2(pR, pA, pGFE);
+}
+
#define GFP_LT(a,b,size) (-1==cpGFpElementCmp((a),(b),(size)))
#define GFP_EQ(a,b,size) ( 0==cpGFpElementCmp((a),(b),(size)))
@@ -167,6 +213,7 @@ int cpGFpGetSize(int feBitSize, int peBitSize, int numpe);
#define cpGFpInitGFp OWNAPI(cpGFpInitGFp)
IppStatus cpGFpInitGFp(int primeBitSize, IppsGFpState* pGF);
+
#define cpGFpSetGFp OWNAPI(cpGFpSetGFp)
IppStatus cpGFpSetGFp(const BNU_CHUNK_T* pPrime, int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF);
@@ -186,31 +233,16 @@ BNU_CHUNK_T* cpGFpSetOctString(BNU_CHUNK_T* pR, const Ipp8u* pStr, int strSize,
#define cpGFpGetOctString OWNAPI(cpGFpGetOctString)
Ipp8u* cpGFpGetOctString(Ipp8u* pStr, int strSize, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
-#define cpGFpNeg OWNAPI(cpGFpNeg)
-BNU_CHUNK_T* cpGFpNeg (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
-
#define cpGFpInv OWNAPI(cpGFpInv)
BNU_CHUNK_T* cpGFpInv (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
-#define cpGFpHalve OWNAPI(cpGFpHalve)
-BNU_CHUNK_T* cpGFpHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
-
-#define cpGFpAdd OWNAPI(cpGFpAdd)
-BNU_CHUNK_T* cpGFpAdd (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE);
-
-#define cpGFpSub OWNAPI(cpGFpSub)
-BNU_CHUNK_T* cpGFpSub (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE);
-
-#define cpGFpMul OWNAPI(cpGFpMul)
-BNU_CHUNK_T* cpGFpMul (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE);
-
-#define cpGFpSqr OWNAPI(cpGFpSqr)
-BNU_CHUNK_T* cpGFpSqr (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
-
#define cpGFpExp OWNAPI(cpGFpExp)
BNU_CHUNK_T* cpGFpExp (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, gsModEngine* pGFE);
#define cpGFpSqrt OWNAPI(cpGFpSqrt)
int cpGFpSqrt(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE);
+#define cpGFEqnr OWNAPI(cpGFEqnr)
+void cpGFEqnr(gsModEngine* pGFE);
+
#endif /* _PCP_GFP_H_ */
diff --git a/ext/ipp/sources/ippcp/pcpgfpsub.c b/ext/ipp/sources/ippcp/pcpgfpsub.c
new file mode 100644
index 0000000..dd4dde6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsub.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSub()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsGFpSub
+//
+// Purpose: Subtract of GF elements
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSub,(const IppsGFpElement* pA, const IppsGFpElement* pB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+
+ GFP_METHOD(pGFE)->sub(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pB), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpsubpe.c b/ext/ipp/sources/ippcp/pcpgfpsubpe.c
new file mode 100644
index 0000000..ba147ba
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpsubpe.c
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p).
+//
+// Context:
+// ippsGFpSub_PE()
+//
+*/
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsGFpSub_PE
+//
+// Purpose: Subtract of GF element and parent GF element
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFp
+// NULL == pA
+// NULL == pR
+// NULL == pParentB
+//
+// ippStsContextMatchErr invalid pGFp->idCtx
+// invalid pA->idCtx
+// invalid pR->idCtx
+// invalid pParentB->idCtx
+//
+// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
+//
+// ippStsBadArgErr pGFp does not specify prime field
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pA Pointer to the context of the first finite field element.
+// pParentB Pointer to the context of the second finite field element.
+// pR Pointer to the context of the result finite field element.
+// pGFp Pointer to the context of the finite field.
+//
+*F*/
+
+IPPFUN(IppStatus, ippsGFpSub_PE,(const IppsGFpElement* pA, const IppsGFpElement* pParentB,
+ IppsGFpElement* pR, IppsGFpState* pGFp))
+{
+ IPP_BAD_PTR4_RET(pA, pParentB, pR, pGFp);
+ pGFp = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFp, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGFp), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pParentB), ippStsContextMatchErr );
+ IPP_BADARG_RET( !GFPE_TEST_ID(pR), ippStsContextMatchErr );
+ {
+ gsModEngine* pGFE = GFP_PMA(pGFp);
+ IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
+ IPP_BADARG_RET( (GFPE_ROOM(pA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
+ IPP_BADARG_RET( (GFPE_ROOM(pParentB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
+
+ cpGFpxSub_GFE(GFPE_DATA(pR), GFPE_DATA(pA), GFPE_DATA(pParentB), pGFE);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx.c b/ext/ipp/sources/ippcp/pcpgfpx.c
new file mode 100644
index 0000000..24b9f78
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p) ectension.
+//
+// Context:
+// pcpgfpec_initgfpxctx.c()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/* the "static" specificator removed because of incorrect result under Linux-32, p8
+ what's wrong? not know maybe compiler (icl 2017)
+ need to check after switchng on icl 2018
+ */
+/*static*/
+void InitGFpxCtx(const IppsGFpState* pGroundGF, int extDeg, const IppsGFpMethod* method, IppsGFpState* pGFpx)
+{
+ gsModEngine* pGFEp = GFP_PMA(pGroundGF);
+ int elemLen = extDeg * GFP_FELEN(pGFEp);
+ int elemLen32 = extDeg * GFP_FELEN32(pGFEp);
+
+ Ipp8u* ptr = (Ipp8u*)pGFpx + sizeof(IppsGFpState);
+
+ /* context identifier */
+ GFP_ID(pGFpx) = idCtxGFP;
+ GFP_PMA(pGFpx) = (gsModEngine*)ptr;
+ {
+ gsModEngine* pGFEx = GFP_PMA(pGFpx);
+
+ /* clear whole context */
+ PaddBlock(0, ptr, sizeof(gsModEngine));
+ ptr += sizeof(gsModEngine);
+
+ GFP_PARENT(pGFEx) = pGFEp;
+ GFP_EXTDEGREE(pGFEx) = extDeg;
+ GFP_FEBITLEN(pGFEx) = 0;//elemBitLen;
+ GFP_FELEN(pGFEx) = elemLen;
+ GFP_FELEN32(pGFEx) = elemLen32;
+ GFP_PELEN(pGFEx) = elemLen;
+ GFP_METHOD(pGFEx) = method->arith;
+ GFP_MODULUS(pGFEx) = (BNU_CHUNK_T*)(ptr); ptr += elemLen * sizeof(BNU_CHUNK_T); /* field polynomial */
+ GFP_POOL(pGFEx) = (BNU_CHUNK_T*)(ptr); /* pool */
+ GFP_MAXPOOL(pGFEx) = GFPX_POOL_SIZE;
+ GFP_USEDPOOL(pGFEx) = 0;
+
+ cpGFpElementPadd(GFP_MODULUS(pGFEx), elemLen, 0);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_add_gfe.c b/ext/ipp/sources/ippcp/pcpgfpx_add_gfe.c
new file mode 100644
index 0000000..6f8866a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_add_gfe.c
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxAdd_GFE()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxAdd_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
+{
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_add addF = MOD_METHOD(pGroundGFE)->add;
+
+ if(pR != pA) {
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+ int deg = GFP_EXTDEGREE(pGFEx);
+ cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1));
+ }
+ return addF(pR, pA, pGroundB, pGroundGFE);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_conj.c b/ext/ipp/sources/ippcp/pcpgfpx_conj.c
new file mode 100644
index 0000000..09a817e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_conj.c
@@ -0,0 +1,65 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxConj()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxConj(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
+{
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ if(pR != pA)
+ cpGFpElementCopy(pR, pA, groundElemLen);
+ MOD_METHOD(pGroundGFE)->neg(pR+groundElemLen, pA+groundElemLen, pGroundGFE);
+
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_exp.c b/ext/ipp/sources/ippcp/pcpgfpx_exp.c
new file mode 100644
index 0000000..3f46448
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_exp.c
@@ -0,0 +1,217 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxExp()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+static int div_upper(int a, int d)
+{ return (a+d-1)/d; }
+
+
+#if defined(_IPP_OWN_DBG_)
+
+#include <stdio.h>
+//#define _IPP_OWN_DBG_
+static void printBNU(const char* note, Ipp64u* pData, int len, int nt)
+{
+ int n, k;
+
+ if(note)
+ printf("%s", note);
+
+ for(n=0, k=0; n<len; n++) {
+ Ipp64u x = pData[n];
+ printf("%016I64x ", x);
+ k++;
+ if(k==nt) {
+ printf("\n");
+ k = 0;
+ }
+ }
+ printf("\n");
+}
+
+#endif /* #if defined(_IPP_OWN_DBG_) */
+
+
+/* sscm version */
+BNU_CHUNK_T* cpGFpxExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE,
+ gsModEngine* pGFEx, Ipp8u* pScratchBuffer)
+{
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+
+ /* remove leding zeros */
+ FIX_BNU(pE, nsE);
+
+ {
+ mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul and sqr methods */
+ mod_sqr sqrF = GFP_METHOD(pGFEx)->sqr;
+
+ BNU_CHUNK_T* pScratchAligned; /* aligned scratch buffer */
+ int nAllocation = 0; /* points from the pool */
+
+ /* size of element */
+ int elmLen = GFP_FELEN(pGFEx);
+
+ /* exponent bitsize */
+ int expBitSize = BITSIZE_BNU(pE, nsE);
+ /* optimal size of window */
+ int w = (NULL==pScratchBuffer)? 1 : cpGFpGetOptimalWinSize(expBitSize);
+ /* number of table entries */
+ int nPrecomputed = 1<<w;
+
+ int poolElmLen = GFP_PELEN(pGFEx);
+ BNU_CHUNK_T* pExpandedE = cpGFpGetPool(1, pGFEx);
+ BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFEx);
+ //tbcd: temporary excluded: assert(NULL!=pExpandedE && NULL!=pTmp);
+
+ if(NULL==pScratchBuffer) {
+ nAllocation = 2 + div_upper(CACHE_LINE_SIZE, poolElmLen*sizeof(BNU_CHUNK_T));
+ pScratchBuffer = (Ipp8u*)cpGFpGetPool(nAllocation, pGFEx);
+ //tbcd: temporary excluded: assert(NULL!=pScratchBuffer);
+ }
+ pScratchAligned = (BNU_CHUNK_T*)( IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE) );
+
+ #if defined(_IPP_OWN_DBG_)
+ printf("precom tbl:\n");
+ #endif
+ /* pre-compute auxiliary table t[] = {A^0, A^1, A^2, ..., A^(2^w-1)} */
+ cpGFpElementCopyPadd(pTmp, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
+ //cpScramblePut(pScratchAligned+0, nPrecomputed, (Ipp8u*)pTmp, elmDataSize);
+ gsScramblePut(pScratchAligned, 0, pTmp, elmLen, w);
+ #if defined(_IPP_OWN_DBG_)
+ printBNU("precom tbl:\n", pTmp, 48, 6);
+ #endif
+
+ { /* pre compute multiplication table */
+ int n;
+ for(n=1; n<nPrecomputed; n++) {
+ mulF(pTmp, pTmp, pA, pGFEx);
+ //cpScramblePut(pScratchAligned+n, nPrecomputed, (Ipp8u*)pTmp, elmDataSize);
+ gsScramblePut(pScratchAligned, n, pTmp, elmLen, w);
+ #if defined(_IPP_OWN_DBG_)
+ printBNU("precom tbl:\n", pTmp, 48, 6);
+ #endif
+ }
+ }
+
+ {
+ /* copy exponent value */
+ cpGFpElementCopy(pExpandedE, pE, nsE);
+
+ /* expand exponent value */
+ ((Ipp32u*)pExpandedE)[BITS2WORD32_SIZE(expBitSize)] = 0;
+ expBitSize = ((expBitSize+w-1)/w)*w;
+
+ #if defined(_IPP_OWN_DBG_)
+ printf("\nexponentiation:\n");
+ #endif
+ /*
+ // exponentiation
+ */
+ {
+ /* digit mask */
+ BNU_CHUNK_T dmask = nPrecomputed-1;
+
+ /* position (bit number) of the leftmost window */
+ int wPosition = expBitSize-w;
+
+ /* extract leftmost window value */
+ Ipp32u eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u)));
+ int shift = wPosition & 0xF;
+ Ipp32u windowVal = (eChunk>>shift) & dmask;
+
+ /* initialize result */
+ //cpScrambleGet((Ipp8u*)pR, elmDataSize, pScratchAligned+windowVal, nPrecomputed);
+ gsScrambleGet_sscm(pR, elmLen, pScratchAligned, windowVal, w);
+ #if defined(_IPP_OWN_DBG_)
+ printBNU("init result:\n", pR, 48, 6);
+ #endif
+
+ for(wPosition-=w; wPosition>=0; wPosition-=w) {
+ int k;
+ #if defined(_IPP_OWN_DBG_)
+ printf("\nwPosition=%d\n", wPosition);
+ #endif
+ /* w times squaring */
+ for(k=0; k<w; k++) {
+ sqrF(pR, pR, pGFEx);
+ #if defined(_IPP_OWN_DBG_)
+ printBNU("sqr:\n", pR, 48, 6);
+ #endif
+ }
+
+ /* extract next window value */
+ eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u)));
+ shift = wPosition & 0xF;
+ windowVal = (eChunk>>shift) & dmask;
+
+ /* extract value from the pre-computed table */
+ //cpScrambleGet((Ipp8u*)pTmp, elmDataSize, pScratchAligned+windowVal, nPrecomputed);
+ gsScrambleGet_sscm(pTmp, elmLen, pScratchAligned, windowVal, w);
+
+ /* and multiply */
+ mulF(pR, pR, pTmp, pGFEx);
+ #if defined(_IPP_OWN_DBG_)
+ printBNU("mul:\n", pR, 48, 6);
+ #endif
+ }
+ }
+
+ }
+
+ cpGFpReleasePool(nAllocation+2, pGFEx);
+
+ return pR;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_get.c b/ext/ipp/sources/ippcp/pcpgfpx_get.c
new file mode 100644
index 0000000..de2b944
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_get.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxGet()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxGet(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pE, gsModEngine* pGFEx)
+{
+ cpGFpElementPadd(pDataA, nsA, 0);
+
+ if( GFP_IS_BASIC(pGFEx) )
+ return cpGFpGet(pDataA, nsA, pE, pGFEx);
+
+ else {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+
+ BNU_CHUNK_T* pTmp = pDataA;
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ int deg;
+ for(deg=0; deg<basicDeg && nsA>0; deg++) {
+ int pieceA = IPP_MIN(nsA, basicElemLen);
+
+ cpGFpGet(pTmp, pieceA, pE, pBasicGFE);
+ pE += basicElemLen;
+ pTmp += pieceA;
+ nsA -= pieceA;
+ }
+
+ return pDataA;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_getpolyterm.c b/ext/ipp/sources/ippcp/pcpgfpx_getpolyterm.c
new file mode 100644
index 0000000..680d683
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_getpolyterm.c
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxGetPolyTerm()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxGetPolyTerm(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pE, int deg, gsModEngine* pGFEx)
+{
+ pE += deg * GFP_FELEN(pGFEx);
+ return cpGFpxGet(pDataA, nsA, pE, pGFEx);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_inv.c b/ext/ipp/sources/ippcp/pcpgfpx_inv.c
new file mode 100644
index 0000000..e03e248
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_inv.c
@@ -0,0 +1,246 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxInv()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+static BNU_CHUNK_T* gfpxPolyDiv(BNU_CHUNK_T* pQ, BNU_CHUNK_T* pR,
+ const BNU_CHUNK_T* pA,
+ const BNU_CHUNK_T* pB,
+ gsModEngine* pGFEx)
+{
+ if( GFP_IS_BASIC(pGFEx) )
+ return NULL;
+
+ else {
+ int elemLen = GFP_FELEN(pGFEx);
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int termLen = GFP_FELEN(pGroundGFE);
+
+ int degA = degree(pA, pGFEx);
+ int degB = degree(pB, pGFEx);
+
+ if(degB==0) {
+ if( GFP_IS_ZERO(pB, termLen) )
+ return NULL;
+ else {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGroundGFE);
+
+ cpGFpInv(pR, pB, pBasicGFE);
+ cpGFpElementPadd(pR+GFP_FELEN(pGroundGFE), termLen-GFP_FELEN(pGroundGFE), 0);
+ cpGFpxMul_GFE(pQ, pA, pR, pGFEx);
+ cpGFpElementPadd(pR, elemLen, 0);
+ return pR;
+ }
+ }
+
+ if(degA < degB) {
+ cpGFpElementPadd(pQ, elemLen, 0);
+ cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen);
+ return pR;
+ }
+
+ else {
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ int i, j;
+ BNU_CHUNK_T* pProduct = cpGFpGetPool(2, pGroundGFE);
+ BNU_CHUNK_T* pInvB = pProduct + GFP_PELEN(pGroundGFE);
+ //tbcd: temporary excluded: assert(NULL!=pProduct);
+
+ cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen);
+ cpGFpElementPadd(pQ, elemLen, 0);
+
+ cpGFpxInv(pInvB, GFPX_IDX_ELEMENT(pB, degB, termLen), pGroundGFE);
+
+ for(i=0; i<=degA-degB && !GFP_IS_ZERO(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen); i++) {
+ /* compute q term */
+ mulF(GFPX_IDX_ELEMENT(pQ, degA-degB-i, termLen),
+ GFPX_IDX_ELEMENT(pR, degA-i, termLen),
+ pInvB,
+ pGroundGFE);
+
+ /* R -= B * q */
+ cpGFpElementPadd(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen, 0);
+ for(j=0; j<degB; j++) {
+ mulF(pProduct,
+ GFPX_IDX_ELEMENT(pB, j ,termLen),
+ GFPX_IDX_ELEMENT(pQ, degA-degB-i, termLen),
+ pGroundGFE);
+ subF(GFPX_IDX_ELEMENT(pR, degA-degB-i+j, termLen),
+ GFPX_IDX_ELEMENT(pR, degA-degB-i+j, termLen),
+ pProduct,
+ pGroundGFE);
+ }
+ }
+
+ cpGFpReleasePool(2, pGroundGFE);
+ return pR;
+ }
+ }
+}
+
+
+static BNU_CHUNK_T* gfpxGeneratorDiv(BNU_CHUNK_T* pQ, BNU_CHUNK_T* pR, const BNU_CHUNK_T* pB, gsModEngine* pGFEx)
+{
+ if( GFP_IS_BASIC(pGFEx) )
+ return NULL;
+
+ else {
+ int elemLen = GFP_FELEN(pGFEx);
+
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ int termLen = GFP_FELEN(pGroundGFE);
+
+ BNU_CHUNK_T* pInvB = cpGFpGetPool(2, pGroundGFE);
+ BNU_CHUNK_T* pTmp = pInvB + GFP_PELEN(pGroundGFE);
+
+ int degB = degree(pB, pGFEx);
+ int i;
+
+ //tbcd: temporary excluded: assert(NULL!=pInvB);
+
+ cpGFpElementCopy(pR, GFP_MODULUS(pGFEx), elemLen);
+ cpGFpElementPadd(pQ, elemLen, 0);
+
+ cpGFpxInv(pInvB, GFPX_IDX_ELEMENT(pB, degB, termLen), pGroundGFE);
+
+ for(i=0; i<degB; i++) {
+ BNU_CHUNK_T* ptr;
+ mulF(pTmp, pInvB, GFPX_IDX_ELEMENT(pB, i, termLen), pGroundGFE);
+ ptr = GFPX_IDX_ELEMENT(pR, GFP_EXTDEGREE(pGFEx)-degB+i, termLen);
+ subF(ptr, ptr, pTmp, pGroundGFE);
+ }
+
+ gfpxPolyDiv(pQ, pR, pR, pB, pGFEx);
+
+ cpGFpElementCopy(GFPX_IDX_ELEMENT(pQ, GFP_EXTDEGREE(pGFEx)-degB, termLen), pInvB, termLen);
+
+ cpGFpReleasePool(2, pGroundGFE);
+ return pR;
+ }
+}
+
+BNU_CHUNK_T* cpGFpxInv(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
+{
+ if( GFP_IS_BASIC(pGFEx) )
+ return cpGFpInv(pR, pA, pGFEx);
+
+ if(0==degree(pA, pGFEx)) {
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ BNU_CHUNK_T* tmpR = cpGFpGetPool(1, pGroundGFE);
+ //tbcd: temporary excluded: assert(NULL!=tmpR);
+
+ cpGFpxInv(tmpR, pA, pGroundGFE);
+
+ cpGFpElementCopyPadd(pR, GFP_FELEN(pGFEx), tmpR, GFP_FELEN(pGroundGFE));
+ cpGFpReleasePool(1, pGroundGFE);
+ return pR;
+ }
+
+ else {
+ int elemLen = GFP_FELEN(pGFEx);
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+
+ int pxVars = 6;
+ int pelemLen = GFP_PELEN(pGFEx);
+ BNU_CHUNK_T* lastrem = cpGFpGetPool(pxVars, pGFEx);
+ BNU_CHUNK_T* rem = lastrem + pelemLen;
+ BNU_CHUNK_T* quo = rem + pelemLen;
+ BNU_CHUNK_T* lastaux = quo + pelemLen;
+ BNU_CHUNK_T* aux = lastaux + pelemLen;
+ BNU_CHUNK_T* temp = aux + pelemLen;
+ //tbcd: temporary excluded: assert(NULL!=lastrem);
+
+ cpGFpElementCopy(lastrem, pA, elemLen);
+ cpGFpElementCopyPadd(lastaux, elemLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
+
+ gfpxGeneratorDiv(quo, rem, pA, pGFEx);
+ cpGFpxNeg(aux, quo, pGFEx);
+
+ while(degree(rem, pGFEx) > 0) {
+ gfpxPolyDiv(quo, temp, lastrem, rem, pGFEx);
+ SWAP_PTR(BNU_CHUNK_T, rem, lastrem); //
+ SWAP_PTR(BNU_CHUNK_T, temp, rem);
+
+ GFP_METHOD(pGFEx)->neg(quo, quo, pGFEx);
+ GFP_METHOD(pGFEx)->mul(temp, quo, aux, pGFEx);
+ GFP_METHOD(pGFEx)->add(temp, lastaux, temp, pGFEx);
+ SWAP_PTR(BNU_CHUNK_T, aux, lastaux);
+ SWAP_PTR(BNU_CHUNK_T, temp, aux);
+ }
+ if (GFP_IS_ZERO(rem, elemLen)) { /* gcd != 1 */
+ cpGFpReleasePool(pxVars, pGFEx);
+ return NULL;
+ }
+
+ {
+ BNU_CHUNK_T* invRem = cpGFpGetPool(1, pGroundGFE);
+ //tbcd: temporary excluded: assert(NULL!=invRem);
+
+ cpGFpxInv(invRem, rem, pGroundGFE);
+ cpGFpxMul_GFE(pR, aux, invRem, pGFEx);
+
+ cpGFpReleasePool(1, pGroundGFE);
+ }
+
+ cpGFpReleasePool(pxVars, pGFEx);
+
+ return pR;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_mul_gfe.c b/ext/ipp/sources/ippcp/pcpgfpx_mul_gfe.c
new file mode 100644
index 0000000..28af527
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_mul_gfe.c
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxMul_GFE()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxMul_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
+{
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul mulF = MOD_METHOD(pGroundGFE)->mul;
+
+ int grounfElemLen = GFP_FELEN(pGroundGFE);
+
+ BNU_CHUNK_T* pTmp = pR;
+
+ int deg;
+ for(deg=0; deg<GFP_EXTDEGREE(pGFEx); deg++) {
+ mulF(pTmp, pA, pGroundB, pGroundGFE);
+ pTmp += grounfElemLen;
+ pA += grounfElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_multiexp.c b/ext/ipp/sources/ippcp/pcpgfpx_multiexp.c
new file mode 100644
index 0000000..7d2522d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_multiexp.c
@@ -0,0 +1,204 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxMultiExp()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+static int GetIndex(const BNU_CHUNK_T* ppE[], int nItems, int nBit)
+{
+ int shift = nBit%BYTESIZE;
+ int offset= nBit/BYTESIZE;
+ int index = 0;
+
+ int n;
+ for(n=nItems; n>0; n--) {
+ const Ipp8u* pE = ((Ipp8u*)ppE[n-1]) + offset;
+ Ipp8u e = pE[0];
+ index <<= 1;
+ index += (e>>shift) &1;
+ }
+ return index;
+}
+
+
+static void cpPrecomputeMultiExp(BNU_CHUNK_T* pTable, const BNU_CHUNK_T* ppA[], int nItems, gsModEngine* pGFEx)
+{
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+
+ //int nPrecomputed = 1<<nItems;
+
+ /* length of element (BNU_CHUNK_T) */
+ int elmLen = GFP_FELEN(pGFEx);
+
+ /* get resource */
+ BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFEx);
+ //tbcd: temporary excluded: assert(NULL!=pT);
+
+ /* pTable[0] = 1 */
+ cpGFpElementCopyPadd(pT, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
+ //cpScramblePut(pTable+0, nPrecomputed, (Ipp8u*)pT, elmDataSize);
+ gsScramblePut(pTable, 0, pT, elmLen, nItems);
+ /* pTable[1] = A[0] */
+ //cpScramblePut(pTable+1, nPrecomputed, (Ipp8u*)(ppA[0]), elmDataSize);
+ gsScramblePut(pTable, 1, ppA[0], elmLen, nItems);
+
+ {
+ mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul method */
+
+ int i, baseIdx;
+ for(i=1, baseIdx=2; i<nItems; i++, baseIdx*=2) {
+ /* pTable[baseIdx] = A[i] */
+ //cpScramblePut(pTable+baseIdx, nPrecomputed, (Ipp8u*)(ppA[i]), elmDataSize);
+ gsScramblePut(pTable, baseIdx, ppA[i], elmLen, nItems);
+
+ {
+ int nPasses = 1;
+ int step = baseIdx/2;
+
+ int k;
+ for(k=i-1; k>=0; k--) {
+ int tblIdx = baseIdx;
+
+ int n;
+ for(n=0; n<nPasses; n++, tblIdx+=2*step) {
+ /* use pre-computed value */
+ //cpScrambleGet((Ipp8u*)pT, elmDataSize, pTable+tblIdx, nPrecomputed);
+ gsScrambleGet(pT, elmLen, pTable, tblIdx, nItems);
+ mulF(pT, pT, ppA[k], pGFEx);
+ //cpScramblePut(pTable+tblIdx+step, nPrecomputed, (Ipp8u*)pT, elmDataSize);
+ gsScramblePut(pTable, tblIdx+step, pT, elmLen, nItems);
+ }
+
+ nPasses *= 2;
+ step /= 2;
+ }
+ }
+ }
+ }
+
+ /* release resourse */
+ cpGFpReleasePool(1, pGFEx);
+}
+
+
+static int cpGetMaxBitsizeExponent(const BNU_CHUNK_T* ppE[], int nsE[], int nItems)
+{
+ int n;
+ /* find out the longest exponent */
+ int expBitSize = BITSIZE_BNU(ppE[0], nsE[0]);
+ for(n=1; n<nItems; n++) {
+ expBitSize = IPP_MAX(expBitSize, BITSIZE_BNU(ppE[n], nsE[n]));
+ }
+ return expBitSize;
+}
+
+/* sscm version */
+BNU_CHUNK_T* cpGFpxMultiExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* ppA[], const BNU_CHUNK_T* ppE[], int nsE[], int nItems,
+ gsModEngine* pGFEx, Ipp8u* pScratchBuffer)
+{
+ /* align scratch buffer */
+ BNU_CHUNK_T* pTable = (BNU_CHUNK_T*)( IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE) );
+ /* pre-compute table */
+ cpPrecomputeMultiExp(pTable, ppA, nItems, pGFEx);
+
+ {
+ mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul and sqr methods and parameter */
+ mod_sqr sqrF = GFP_METHOD(pGFEx)->sqr;
+ int elmLen = GFP_FELEN(pGFEx);
+
+ /* find out the longest exponent */
+ int expBitSize = cpGetMaxBitsizeExponent(ppE, nsE, nItems);
+
+ /* allocate resource and copy expanded exponents into */
+ const BNU_CHUNK_T* ppExponent[IPP_MAX_EXPONENT_NUM];
+ {
+ int n;
+ for(n=0; n<nItems; n++) {
+ BNU_CHUNK_T* pData = cpGFpGetPool(1, pGFEx);
+ //tbcd: temporary excluded: assert(NULL!=pData);
+ cpGFpElementCopyPadd(pData, elmLen, ppE[n], nsE[n]);
+ ppExponent[n] = pData;
+ }
+ }
+
+ /* multiexponentiation */
+ {
+ /* get temporary */
+ BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFEx);
+
+ /* init result */
+ int tblIdx = GetIndex(ppExponent, nItems, --expBitSize);
+ //cpScrambleGet((Ipp8u*)pR, elmDataSize, pScratchBuffer+tblIdx, nPrecomputed);
+ gsScrambleGet_sscm(pR, elmLen, pTable, tblIdx, nItems);
+
+ //tbcd: temporary excluded: assert(NULL!=pT);
+
+ /* compute the rest: square and multiply */
+ for(--expBitSize; expBitSize>=0; expBitSize--) {
+ sqrF(pR, pR, pGFEx);
+ tblIdx = GetIndex(ppExponent, nItems, expBitSize);
+ //cpScrambleGet((Ipp8u*)pT, elmDataSize, pScratchBuffer+tblIdx, nPrecomputed);
+ gsScrambleGet_sscm(pT, elmLen, pTable, tblIdx, nItems);
+ mulF(pR, pR, pT, pGFEx);
+ }
+
+ /* release resourse */
+ cpGFpReleasePool(1, pGFEx);
+ }
+
+ /* release resourse */
+ cpGFpReleasePool(nItems, pGFEx);
+
+ return pR;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_neg.c b/ext/ipp/sources/ippcp/pcpgfpx_neg.c
new file mode 100644
index 0000000..158a372
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_neg.c
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxNeg()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
+{
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ GFP_METHOD(pBasicGFE)->neg(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_rand.c b/ext/ipp/sources/ippcp/pcpgfpx_rand.c
new file mode 100644
index 0000000..a40063c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_rand.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxRand()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+
+BNU_CHUNK_T* cpGFpxRand(BNU_CHUNK_T* pR, gsModEngine* pGFEx, IppBitSupplier rndFunc, void* pRndParam)
+{
+ if( GFP_IS_BASIC(pGFEx) )
+ return cpGFpRand(pR, pGFEx, rndFunc, pRndParam);
+
+ else {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ if(NULL == cpGFpRand(pTmp, pBasicGFE, rndFunc, pRndParam))
+ break;
+ pTmp += basicElemLen;
+ }
+ return deg==basicDeg? pR : NULL;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_set.c b/ext/ipp/sources/ippcp/pcpgfpx_set.c
new file mode 100644
index 0000000..a260916
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_set.c
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxSet()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxSet(BNU_CHUNK_T* pE, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFEx)
+{
+ if( GFP_IS_BASIC(pGFEx) )
+ return cpGFpSet(pE, pDataA, nsA, pGFEx);
+
+ else {
+ gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+
+ BNU_CHUNK_T* pTmpE = pE;
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ int deg, error;
+ for(deg=0, error=0; deg<basicDeg && !error; deg++) {
+ int pieceA = IPP_MIN(nsA, basicElemLen);
+
+ error = NULL == cpGFpSet(pTmpE, pDataA, pieceA, pBasicGFE);
+ pTmpE += basicElemLen;
+ pDataA += pieceA;
+ nsA -= pieceA;
+ }
+
+ return (deg<basicDeg)? NULL : pE;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_setpolyterm.c b/ext/ipp/sources/ippcp/pcpgfpx_setpolyterm.c
new file mode 100644
index 0000000..6816e96
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_setpolyterm.c
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxSetPolyTerm()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxSetPolyTerm(BNU_CHUNK_T* pE, int deg, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFEx)
+{
+ pE += deg * GFP_FELEN(pGFEx);
+ return cpGFpxSet(pE, pDataA, nsA, pGFEx);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpx_sub_gfe.c b/ext/ipp/sources/ippcp/pcpgfpx_sub_gfe.c
new file mode 100644
index 0000000..f1e5cf4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpx_sub_gfe.c
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpxSub_GFE()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+BNU_CHUNK_T* cpGFpxSub_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
+{
+ gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_sub subF = MOD_METHOD(pGroundGFE)->sub;
+
+ if(pR != pA) {
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+ int deg = GFP_EXTDEGREE(pGFEx);
+ cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1));
+ }
+ return subF(pR, pA, pGroundB, pGroundGFE);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxgetsize.c b/ext/ipp/sources/ippcp/pcpgfpxgetsize.c
new file mode 100644
index 0000000..f74ec01
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxgetsize.c
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p) ectension.
+//
+// Context:
+// pcpgfpxgetsize.c()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+/* Get context size */
+static int cpGFExGetSize(int elemLen, int pelmLen, int numpe)
+{
+ int ctxSize = 0;
+
+ /* size of GFp engine */
+ ctxSize = sizeof(gsModEngine)
+ + elemLen*sizeof(BNU_CHUNK_T) /* modulus */
+ + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* pool */
+
+ ctxSize = sizeof(IppsGFpState) /* size of IppsGFPState*/
+ + ctxSize; /* GFpx engine */
+ return ctxSize;
+}
+
+/*F*
+// Name: ippsGFpxGetSize
+//
+// Purpose: Gets the size of the context of a GF(p^d) field.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL.
+// ippStsContextMatchErr !GFP_TEST_ID(pGroundGF)
+// ippStsBadArgErr degree is greater than or equal to 9 or is less than 2.
+// ippStsNoErr no error
+//
+// Parameters:
+// pGroundGF Pointer to the context of the finite field GF(p) being extended.
+// degree Degree of the extension.
+// pSize Pointer to the buffer size, in bytes, needed for the IppsGFpState
+// context. //
+*F*/
+
+IPPFUN(IppStatus, ippsGFpxGetSize, (const IppsGFpState* pGroundGF, int degree, int* pSize))
+{
+ IPP_BAD_PTR2_RET(pGroundGF, pSize);
+ IPP_BADARG_RET( degree<IPP_MIN_GF_EXTDEG || degree >IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
+ pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
+
+ #define MAX_GFx_SIZE (1<<15) /* max size (bytes) of GF element (32KB) */
+ {
+ int groundElmLen = GFP_FELEN(GFP_PMA(pGroundGF));
+ Ipp64u elmLen64 = (Ipp64u)(groundElmLen) *sizeof(BNU_CHUNK_T) *degree;
+ int elemLen = (int)LODWORD(elmLen64);
+ *pSize = 0;
+ IPP_BADARG_RET(elmLen64> MAX_GFx_SIZE, ippStsBadArgErr);
+
+ *pSize = cpGFExGetSize(elemLen, elemLen, GFPX_POOL_SIZE)
+ + GFP_ALIGNMENT;
+ return ippStsNoErr;
+ }
+ #undef MAX_GFx_SIZE
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxinit.c b/ext/ipp/sources/ippcp/pcpgfpxinit.c
new file mode 100644
index 0000000..b3ff300
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxinit.c
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p) ectension.
+//
+// Context:
+// pcpgfpxinit.c()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+
+/*F*
+// Name: ippsGFpxInit
+//
+// Purpose: initializes finite field extension GF(p^d)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFpx
+// NULL == pGroundGF
+// NULL == ppGroundElm
+// NULL == pGFpMethod
+//
+// ippStsContextMatchErr incorrect pGroundGF's context ID
+// incorrect ppGroundElm[i]'s context ID
+//
+// ippStsOutOfRangeErr size of ppGroundElm[i] does not equal to size of pGroundGF element
+//
+// ippStsBadArgErr IPP_MIN_GF_EXTDEG > extDeg || extDeg > IPP_MAX_GF_EXTDEG
+// (IPP_MIN_GF_EXTDEG==2, IPP_MAX_GF_EXTDEG==8)
+// 1>nElm || nElm>extDeg
+//
+// cpID_Poly!=pGFpMethod->modulusID -- method does not refferenced to polynomial one
+// pGFpMethod->modulusBitDeg!=extDeg -- fixed method does not match to degree extension
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGroundGF pointer to the context of the finite field is being extension
+// extDeg degree of extension
+// ppGroundElm[] pointer to the array of extension field polynomial
+// nElm number of coefficients above
+// pGFpMethod pointer to the basic arithmetic metods
+// pGFpx pointer to Finite Field context is being initialized
+*F*/
+IPPFUN(IppStatus, ippsGFpxInit,(const IppsGFpState* pGroundGF, int extDeg,
+ const IppsGFpElement* const ppGroundElm[], int nElm,
+ const IppsGFpMethod* pGFpMethod, IppsGFpState* pGFpx))
+{
+ IPP_BAD_PTR4_RET(pGFpx, pGroundGF, ppGroundElm, pGFpMethod);
+
+ pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) );
+ pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
+
+ /* test extension degree */
+ IPP_BADARG_RET( extDeg<IPP_MIN_GF_EXTDEG || extDeg>IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
+ /* coeffs at (x^0), (x^1), ..., (x^(deg-1)) passed acually */
+ /* considering normilized f(x), the coeff at (x^deg) is 1 and so could neither stored no passed */
+ /* test if 1<=nElm<=extDeg */
+ IPP_BADARG_RET( 1>nElm || nElm>extDeg, ippStsBadArgErr);
+
+ /* test if method is polynomial based */
+ IPP_BADARG_RET(cpID_Poly != (pGFpMethod->modulusID & cpID_Poly), ippStsBadArgErr);
+ /* test if method is fixed polynomial based */
+ IPP_BADARG_RET(pGFpMethod->modulusBitDeg && (pGFpMethod->modulusBitDeg!=extDeg), ippStsBadArgErr);
+
+ InitGFpxCtx(pGroundGF, extDeg, pGFpMethod, pGFpx);
+
+ {
+ BNU_CHUNK_T* pPoly = GFP_MODULUS(GFP_PMA(pGFpx));
+ int polyTermlen = GFP_FELEN(GFP_PMA(pGroundGF));
+ int n;
+ for(n=0; n<nElm; n++, pPoly+=polyTermlen) {
+ const IppsGFpElement* pGroundElm = ppGroundElm[n];
+
+ /* test element */
+ IPP_BAD_PTR1_RET(pGroundElm);
+ IPP_BADARG_RET(!GFPE_TEST_ID(pGroundElm), ippStsContextMatchErr);
+ IPP_BADARG_RET(GFPE_ROOM(pGroundElm)!=polyTermlen, ippStsOutOfRangeErr);
+
+ /* copy element */
+ cpGFpElementCopy(pPoly, GFPE_DATA(pGroundElm), polyTermlen);
+ }
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxinitbinomial.c b/ext/ipp/sources/ippcp/pcpgfpxinitbinomial.c
new file mode 100644
index 0000000..2f68303
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxinitbinomial.c
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Operations over GF(p) ectension.
+//
+// Context:
+// pcpgfpxinitbinomial.c()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpgfpstuff.h"
+#include "pcpgfpxstuff.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsGFpxInitBinomial
+//
+// Purpose: initializes finite field extension GF(p^d)
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pGFpx
+// NULL == pGroundGF
+// NULL == pGroundElm
+// NULL == pGFpMethod
+//
+// ippStsContextMatchErr incorrect pGroundGF's context ID
+// incorrect pGroundElm's context ID
+//
+// ippStsOutOfRangeErr size of pGroundElm does not equal to size of pGroundGF element
+//
+// ippStsBadArgErr IPP_MIN_GF_EXTDEG > extDeg || extDeg > IPP_MAX_GF_EXTDEG
+// (IPP_MIN_GF_EXTDEG==2, IPP_MAX_GF_EXTDEG==8)
+//
+// cpID_Poly!=pGFpMethod->modulusID -- method does not refferenced to polynomial one
+// pGFpMethod->modulusBitDeg!=extDeg -- fixed method does not match to degree extension
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pGroundGF pointer to the context of the finite field is being extension
+// extDeg degree of extension
+// pGroundElm pointer to the IppsGFpElement context containing the trailing coefficient of the field binomial.
+// pGFpMethod pointer to the basic arithmetic metods
+// pGFpx pointer to Finite Field context is being initialized
+*F*/
+IPPFUN(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, int extDeg,
+ const IppsGFpElement* pGroundElm,
+ const IppsGFpMethod* pGFpMethod,
+ IppsGFpState* pGFpx))
+{
+ IPP_BAD_PTR4_RET(pGFpx, pGroundGF, pGroundElm, pGFpMethod);
+
+ pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) );
+ pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
+ IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
+
+ IPP_BADARG_RET( !GFPE_TEST_ID(pGroundElm), ippStsContextMatchErr );
+ IPP_BADARG_RET(GFPE_ROOM(pGroundElm)!=GFP_FELEN(GFP_PMA(pGroundGF)), ippStsOutOfRangeErr);
+
+ IPP_BADARG_RET( extDeg<IPP_MIN_GF_EXTDEG || extDeg>IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
+
+ /* test method is binomial based */
+ IPP_BADARG_RET(cpID_Binom != (pGFpMethod->modulusID & cpID_Binom), ippStsBadArgErr);
+
+ /* test if method assums fixed degree extension */
+ IPP_BADARG_RET(pGFpMethod->modulusBitDeg && (extDeg!=pGFpMethod->modulusBitDeg), ippStsBadArgErr);
+
+ /* init context */
+ InitGFpxCtx(pGroundGF, extDeg, pGFpMethod, pGFpx);
+
+ /* store low-order coefficient of irresucible into the context */
+ cpGFpElementCopy(GFP_MODULUS(GFP_PMA(pGFpx)), GFPE_DATA(pGroundElm), GFP_FELEN(GFP_PMA(pGroundGF)));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom.c
new file mode 100644
index 0000000..53d0006
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom.c
@@ -0,0 +1,143 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Multiplication in GF(p^d), if field polynomial: g(x) = x^d + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxMul_pd_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
+ int deg = GFP_EXTDEGREE(pGFEx);
+ int elemLen= GFP_FELEN(pGFEx);
+ int groundElemLen = GFP_FELEN(GFP_PARENT(pGFEx));
+ int d;
+
+ BNU_CHUNK_T* R = cpGFpGetPool(4, pGFEx);
+ BNU_CHUNK_T* X = R+elemLen;
+ BNU_CHUNK_T* T0= X+elemLen;
+ BNU_CHUNK_T* T1= T0+elemLen;
+ //tbcd: temporary excluded: assert(NULL!=R);
+
+ /* T0 = A * beta */
+ cpGFpxMul_GFE(T0, pA, pGFpolynomial, pGFEx);
+ /* T1 = A */
+ cpGFpElementCopy(T1, pA, elemLen);
+
+ /* R = A * B[0] */
+ cpGFpxMul_GFE(R, pA, pB, pGFEx);
+
+ /* R += (A*B[d]) mod g() */
+ for(d=1; d<deg; d++) {
+ cpGFpxMul_GFE(X, GFPX_IDX_ELEMENT(T0, deg-d, groundElemLen), GFPX_IDX_ELEMENT(pB, d, groundElemLen), pGFEx);
+ GFP_METHOD(pGFEx)->add(R, R, X, pGFEx);
+ }
+ cpGFpElementCopy(pR, R, elemLen);
+
+ cpGFpReleasePool(4, pGFEx);
+ return pR;
+}
+
+/*
+// Squaring in GF(p^d), if field polynomial: g(x) = x^d + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxSqr_pd_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+#pragma noinline
+ return cpGFpxMul_pd_binom(pR, pA, pA, pGFEx);
+}
+
+/*
+// return specific polynomial arith methods
+// polynomial - general binomial
+*/
+static gsModMethod* gsPolyArith_binom(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_pd_binom,
+ cpGFpxSqr_pd_binom,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(x) = x^d - a0, a0 from GF(p)
+//
+//
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Binom,
+ 0,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith_binom();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom2.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom2.c
new file mode 100644
index 0000000..c8c7f59
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom2.c
@@ -0,0 +1,213 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxmethod_binom_mulc.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Multiplication in GF(p^2), if field polynomial: g(x) = x^2 + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxMul_p2_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+
+ const BNU_CHUNK_T* pB0 = pB;
+ const BNU_CHUNK_T* pB1 = pB+groundElemLen;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(4, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* t2 = t1+groundElemLen;
+ BNU_CHUNK_T* t3 = t2+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ #if defined GS_DBG
+ BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
+ BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
+ #endif
+ #if defined GS_DBG
+ cpGFpxGet(arg0, groundElemLen, pA0, pGroundGFE);
+ cpGFpxGet(arg1, groundElemLen, pB0, pGroundGFE);
+ #endif
+
+ mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
+
+ #if defined GS_DBG
+ cpGFpxGet(arg0, groundElemLen, pA1, pGroundGFE);
+ cpGFpxGet(arg1, groundElemLen, pB1, pGroundGFE);
+ #endif
+
+ mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
+ addF(t2, pA0, pA1, pGroundGFE); /* t2 = a[0]+a[1] */
+ addF(t3, pB0, pB1, pGroundGFE); /* t3 = b[0]+b[1] */
+
+ #if defined GS_DBG
+ cpGFpxGet(arg0, groundElemLen, t2, pGroundGFE);
+ cpGFpxGet(arg1, groundElemLen, t3, pGroundGFE);
+ #endif
+
+ mulF(pR1, t2, t3, pGroundGFE); /* r[1] = (a[0]+a[1]) * (b[0]+b[1]) */
+ subF(pR1, pR1, t0, pGroundGFE); /* r[1] -= a[0]*b[0]) + a[1]*b[1] */
+ subF(pR1, pR1, t1, pGroundGFE);
+
+ cpGFpxMul_G0(t1, t1, pGFEx);
+ subF(pR0, t0, t1, pGroundGFE);
+
+ #if defined GS_DBG
+ cpGFpReleasePool(2, pGroundGFE);
+ #endif
+
+ cpGFpReleasePool(4, pGroundGFE);
+ return pR;
+}
+
+/*
+// Squaring in GF(p^2), if field polynomial: g(x) = x^2 + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxSqr_p2_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(3, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* u0 = t1+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ #if defined GS_DBG
+ BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
+ BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
+ #endif
+ #if defined GS_DBG
+ cpGFpxGet(arg0, groundElemLen, pA0, pGroundGFE);
+ cpGFpxGet(arg1, groundElemLen, pA1, pGroundGFE);
+ #endif
+
+ mulF(u0, pA0, pA1, pGroundGFE); /* u0 = a[0]*a[1] */
+ sqrF(t0, pA0, pGroundGFE); /* t0 = a[0]*a[0] */
+ sqrF(t1, pA1, pGroundGFE); /* t1 = a[1]*a[1] */
+ cpGFpxMul_G0(t1, t1, pGFEx);
+ subF(pR0, t0, t1, pGroundGFE);
+ addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
+
+ #if defined GS_DBG
+ cpGFpReleasePool(2, pGroundGFE);
+ #endif
+
+ cpGFpReleasePool(3, pGroundGFE);
+ return pR;
+}
+
+/*
+// return specific polynomi alarith methods
+// polynomial - deg 2 binomial
+*/
+static gsModMethod* gsPolyArith_binom2(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_p2_binom,
+ cpGFpxSqr_p2_binom,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(x) = x^2 - a0, a0 from GF(p)
+//
+//
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom2, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Binom,
+ 2,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith_binom2();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3.c
new file mode 100644
index 0000000..908b557
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3.c
@@ -0,0 +1,217 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxmethod_binom_mulc.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Multiplication in GF(p^3), if field polynomial: g(x) = x^3 + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxMul_p3_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+ const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
+
+ const BNU_CHUNK_T* pB0 = pB;
+ const BNU_CHUNK_T* pB1 = pB+groundElemLen;
+ const BNU_CHUNK_T* pB2 = pB+groundElemLen*2;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+ BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(6, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* t2 = t1+groundElemLen;
+ BNU_CHUNK_T* u0 = t2+groundElemLen;
+ BNU_CHUNK_T* u1 = u0+groundElemLen;
+ BNU_CHUNK_T* u2 = u1+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ addF(u0 ,pA0, pA1, pGroundGFE); /* u0 = a[0]+a[1] */
+ addF(t0 ,pB0, pB1, pGroundGFE); /* t0 = b[0]+b[1] */
+ mulF(u0, u0, t0, pGroundGFE); /* u0 = (a[0]+a[1])*(b[0]+b[1]) */
+ mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
+
+ addF(u1 ,pA1, pA2, pGroundGFE); /* u1 = a[1]+a[2] */
+ addF(t1 ,pB1, pB2, pGroundGFE); /* t1 = b[1]+b[2] */
+ mulF(u1, u1, t1, pGroundGFE); /* u1 = (a[1]+a[2])*(b[1]+b[2]) */
+ mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
+
+ addF(u2 ,pA2, pA0, pGroundGFE); /* u2 = a[2]+a[0] */
+ addF(t2 ,pB2, pB0, pGroundGFE); /* t2 = b[2]+b[0] */
+ mulF(u2, u2, t2, pGroundGFE); /* u2 = (a[2]+a[0])*(b[2]+b[0]) */
+ mulF(t2, pA2, pB2, pGroundGFE); /* t2 = a[2]*b[2] */
+
+ subF(u0, u0, t0, pGroundGFE); /* u0 = a[0]*b[1]+a[1]*b[0] */
+ subF(u0, u0, t1, pGroundGFE);
+ subF(u1, u1, t1, pGroundGFE); /* u1 = a[1]*b[2]+a[2]*b[1] */
+ subF(u1, u1, t2, pGroundGFE);
+ subF(u2, u2, t2, pGroundGFE); /* u2 = a[2]*b[0]+a[0]*b[2] */
+ subF(u2, u2, t0, pGroundGFE);
+
+ cpGFpxMul_G0(u1, u1, pGFEx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */
+ cpGFpxMul_G0(t2, t2, pGFEx); /* t2 = a[2]*b[2] * beta */
+
+ subF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
+ subF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
+
+ addF(pR2, u2, t1, pGroundGFE); /* r[2] = a[2]*b[0] + a[1]*b[1] + a[0]*b[2] */
+
+ cpGFpReleasePool(6, pGroundGFE);
+ return pR;
+}
+
+/*
+// Squaring in GF(p^3), if field polynomial: g(x) = x^3 + beta => binominal
+*/
+static BNU_CHUNK_T* cpGFpxSqr_p3_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+ const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+ BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
+
+ BNU_CHUNK_T* s0 = cpGFpGetPool(5, pGroundGFE);
+ BNU_CHUNK_T* s1 = s0+groundElemLen;
+ BNU_CHUNK_T* s2 = s1+groundElemLen;
+ BNU_CHUNK_T* s3 = s2+groundElemLen;
+ BNU_CHUNK_T* s4 = s3+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=s0);
+
+ addF(s2, pA0, pA2, pGroundGFE);
+ subF(s2, s2, pA1, pGroundGFE);
+ sqrF(s2, s2, pGroundGFE);
+ sqrF(s0, pA0, pGroundGFE);
+ sqrF(s4, pA2, pGroundGFE);
+ mulF(s1, pA0, pA1, pGroundGFE);
+ mulF(s3, pA1, pA2, pGroundGFE);
+ addF(s1, s1, s1, pGroundGFE);
+ addF(s3, s3, s3, pGroundGFE);
+
+ addF(pR2, s1, s2, pGroundGFE);
+ addF(pR2, pR2, s3, pGroundGFE);
+ subF(pR2, pR2, s0, pGroundGFE);
+ subF(pR2, pR2, s4, pGroundGFE);
+
+ cpGFpxMul_G0(s4, s4, pGFEx);
+ subF(pR1, s1, s4, pGroundGFE);
+
+ cpGFpxMul_G0(s3, s3, pGFEx);
+ subF(pR0, s0, s3, pGroundGFE);
+
+ cpGFpReleasePool(5, pGroundGFE);
+ return pR;
+}
+
+
+/*
+// return specific polynomi alarith methods
+// polynomial - deg 3 binomial
+*/
+static gsModMethod* gsPolyArith_binom3(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_p3_binom,
+ cpGFpxSqr_p3_binom,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(x) = x^3 - a0, a0 from GF(p)
+//
+//
+*F*/
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom3, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Binom,
+ 3,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith_binom3();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3_epid2.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3_epid2.c
new file mode 100644
index 0000000..3dce1b0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom3_epid2.c
@@ -0,0 +1,276 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator over GF((p^2)^3)
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+#include "pcpgfpxmethod_binom_epid2.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Intel(R) Enhanced Privacy ID (Intel(R) EPID) 2.0 specific.
+//
+// Intel(R) EPID 2.0 uses the following finite field hierarchy:
+//
+// 1) prime field GF(p),
+// p = 0xFFFFFFFFFFFCF0CD46E5F25EEE71A49F0CDC65FB12980A82D3292DDBAED33013
+//
+// 2) 2-degree extension of GF(p): GF(p^2) == GF(p)[x]/g(x), g(x) = x^2 -beta,
+// beta =-1 mod p, so "beta" represents as {1}
+//
+// 3) 3-degree extension of GF(p^2) ~ GF(p^6): GF((p^2)^3) == GF(p)[v]/g(v), g(v) = v^3 -xi,
+// xi belongs GF(p^2), xi=x+2, so "xi" represents as {2,1} ---- "2" is low- and "1" is high-order coefficients
+//
+// 4) 2-degree extension of GF((p^2)^3) ~ GF(p^12): GF(((p^2)^3)^2) == GF(p)[w]/g(w), g(w) = w^2 -vi,
+// psi belongs GF((p^2)^3), vi=0*v^2 +1*v +0, so "vi" represents as {0,1,0}---- "0", '1" and "0" are low-, middle- and high-order coefficients
+//
+// See representations in t_gfpparam.cpp
+//
+*/
+
+/*
+// Intel(R) EPID 2.0 specific
+// ~~~~~~~~~~~~~~~
+//
+// Multiplication over GF((p^2)^3)
+// - field polynomial: g(v) = v^3 - xi => binominal with specific value of "xi"
+// - xi = x+2
+*/
+static BNU_CHUNK_T* cpGFpxMul_p3_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+ const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
+
+ const BNU_CHUNK_T* pB0 = pB;
+ const BNU_CHUNK_T* pB1 = pB+groundElemLen;
+ const BNU_CHUNK_T* pB2 = pB+groundElemLen*2;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+ BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(6, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* t2 = t1+groundElemLen;
+ BNU_CHUNK_T* u0 = t2+groundElemLen;
+ BNU_CHUNK_T* u1 = u0+groundElemLen;
+ BNU_CHUNK_T* u2 = u1+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ addF(u0 ,pA0, pA1, pGroundGFE); /* u0 = a[0]+a[1] */
+ addF(t0 ,pB0, pB1, pGroundGFE); /* t0 = b[0]+b[1] */
+ mulF(u0, u0, t0, pGroundGFE); /* u0 = (a[0]+a[1])*(b[0]+b[1]) */
+ mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
+
+ addF(u1 ,pA1, pA2, pGroundGFE); /* u1 = a[1]+a[2] */
+ addF(t1 ,pB1, pB2, pGroundGFE); /* t1 = b[1]+b[2] */
+ mulF(u1, u1, t1, pGroundGFE); /* u1 = (a[1]+a[2])*(b[1]+b[2]) */
+ mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
+
+ addF(u2 ,pA2, pA0, pGroundGFE); /* u2 = a[2]+a[0] */
+ addF(t2 ,pB2, pB0, pGroundGFE); /* t2 = b[2]+b[0] */
+ mulF(u2, u2, t2, pGroundGFE); /* u2 = (a[2]+a[0])*(b[2]+b[0]) */
+ mulF(t2, pA2, pB2, pGroundGFE); /* t2 = a[2]*b[2] */
+
+ subF(u0, u0, t0, pGroundGFE); /* u0 = a[0]*b[1]+a[1]*b[0] */
+ subF(u0, u0, t1, pGroundGFE);
+ subF(u1, u1, t1, pGroundGFE); /* u1 = a[1]*b[2]+a[2]*b[1] */
+ subF(u1, u1, t2, pGroundGFE);
+ subF(u2, u2, t2, pGroundGFE); /* u2 = a[2]*b[0]+a[0]*b[2] */
+ subF(u2, u2, t0, pGroundGFE);
+
+ /* Intel(R) EPID 2.0 specific */
+ {
+ int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
+
+ /* deal with GF(p^2^3) */
+ if(basicExtDegree==6) {
+ cpFq2Mul_xi(u1, u1, pGroundGFE);
+ cpFq2Mul_xi(t2, t2, pGroundGFE);
+ addF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
+ addF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
+ }
+ /* just a case */
+ else {
+ cpGFpxMul_G0(u1, u1, pGFEx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */
+ cpGFpxMul_G0(t2, t2, pGFEx); /* t2 = a[2]*b[2] * beta */
+ subF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
+ subF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
+ }
+ }
+
+ addF(pR2, u2, t1, pGroundGFE); /* r[2] = a[2]*b[0] + a[1]*b[1] + a[0]*b[2] */
+
+ cpGFpReleasePool(6, pGroundGFE);
+ return pR;
+}
+
+/*
+// Intel(R) EPID 2.0 specific
+// ~~~~~~~~~~~~~~~
+//
+// Squaring over GF((p^2)^3)
+// - field polynomial: g(v) = v^3 - xi => binominal with specific value of "xi"
+// - xi = x+2
+*/
+static BNU_CHUNK_T* cpGFpxSqr_p3_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+ const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+ BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
+
+ BNU_CHUNK_T* s0 = cpGFpGetPool(5, pGroundGFE);
+ BNU_CHUNK_T* s1 = s0+groundElemLen;
+ BNU_CHUNK_T* s2 = s1+groundElemLen;
+ BNU_CHUNK_T* s3 = s2+groundElemLen;
+ BNU_CHUNK_T* s4 = s3+groundElemLen;
+
+ addF(s2, pA0, pA2, pGroundGFE);
+ subF(s2, s2, pA1, pGroundGFE);
+ sqrF(s2, s2, pGroundGFE);
+ sqrF(s0, pA0, pGroundGFE);
+ sqrF(s4, pA2, pGroundGFE);
+ mulF(s1, pA0, pA1, pGroundGFE);
+ mulF(s3, pA1, pA2, pGroundGFE);
+ addF(s1, s1, s1, pGroundGFE);
+ addF(s3, s3, s3, pGroundGFE);
+
+ addF(pR2, s1, s2, pGroundGFE);
+ addF(pR2, pR2, s3, pGroundGFE);
+ subF(pR2, pR2, s0, pGroundGFE);
+ subF(pR2, pR2, s4, pGroundGFE);
+
+ /* Intel(R) EPID 2.0 specific */
+ {
+ int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
+
+ /* deal with GF(p^2^3) */
+ if(basicExtDegree==6) {
+ cpFq2Mul_xi(s4, s4, pGroundGFE);
+ cpFq2Mul_xi(s3, s3, pGroundGFE);
+ addF(pR1, s1, s4, pGroundGFE);
+ addF(pR0, s0, s3, pGroundGFE);
+ }
+ /* just a case */
+ else {
+ cpGFpxMul_G0(s4, s4, pGFEx);
+ cpGFpxMul_G0(s3, s3, pGFEx);
+ subF(pR1, s1, s4, pGroundGFE);
+ subF(pR0, s0, s3, pGroundGFE);
+ }
+ }
+
+ cpGFpReleasePool(5, pGroundGFE);
+ return pR;
+}
+
+/*
+// return specific polynomi alarith methods
+// polynomial - deg 3 binomial (Intel(R) EPID 2.0)
+*/
+static gsModMethod* gsPolyArith_binom3_epid2(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_p3_binom_epid2,
+ cpGFpxSqr_p3_binom_epid2,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom3_epid2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(v) = v^3 - U0, U0 from GF(q^2), U0 = u + 2
+//
+//
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom3_epid2, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Binom3_epid20,
+ 3,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith_binom3_epid2();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.c
new file mode 100644
index 0000000..28e3b64
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.c
@@ -0,0 +1,296 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+#include "pcpgfpxmethod_binom_epid2.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Intel(R) Enhanced Privacy ID (Intel(R) EPID) 2.0 specific.
+//
+// Intel(R) EPID 2.0 uses the following finite field hierarchy:
+//
+// 1) prime field GF(p),
+// p = 0xFFFFFFFFFFFCF0CD46E5F25EEE71A49F0CDC65FB12980A82D3292DDBAED33013
+//
+// 2) 2-degree extension of GF(p): GF(p^2) == GF(p)[x]/g(x), g(x) = x^2 -beta,
+// beta =-1 mod p, so "beta" represents as {1}
+//
+// 3) 3-degree extension of GF(p^2) ~ GF(p^6): GF((p^2)^3) == GF(p)[v]/g(v), g(v) = v^3 -xi,
+// xi belongs GF(p^2), xi=x+2, so "xi" represents as {2,1} ---- "2" is low- and "1" is high-order coefficients
+//
+// 4) 2-degree extension of GF((p^2)^3) ~ GF(p^12): GF(((p^2)^3)^2) == GF(p)[w]/g(w), g(w) = w^2 -vi,
+// psi belongs GF((p^2)^3), vi=0*v^2 +1*v +0, so "vi" represents as {0,1,0}---- "0", '1" and "0" are low-, middle- and high-order coefficients
+//
+// See representations in t_gfpparam.cpp
+//
+*/
+
+/*
+// Multiplication case: mul(a, vi) over GF((p^2)^3),
+// where:
+// a, belongs to GF((p^2)^3)
+// xi belongs to GF((p^2)^3), vi={0,1,0}
+//
+// The case is important in GF(((p^2)^3)^2) arithmetic for Intel(R) EPID 2.0.
+//
+*/
+__INLINE BNU_CHUNK_T* cpFq6Mul_vi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ int termLen = GFP_FELEN(pGroundGFE);
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+termLen;
+ const BNU_CHUNK_T* pA2 = pA+termLen*2;
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+termLen;
+ BNU_CHUNK_T* pR2 = pR+termLen*2;
+
+ BNU_CHUNK_T* t = cpGFpGetPool(1, pGroundGFE);
+ //tbcd: temporary excluded: assert(NULL!=t);
+
+ cpFq2Mul_xi(t, pA2, pGroundGFE);
+ cpGFpElementCopy(pR2, pA1, termLen);
+ cpGFpElementCopy(pR1, pA0, termLen);
+ cpGFpElementCopy(pR0, t, termLen);
+
+ cpGFpReleasePool(1, pGroundGFE);
+
+ return pR;
+}
+
+/*
+// Intel(R) EPID 2.0 specific
+// ~~~~~~~~~~~~~~~
+//
+// Multiplication over GF(p^2)
+// - field polynomial: g(x) = x^2 - beta => binominal with specific value of "beta"
+// - beta = p-1
+//
+// Multiplication over GF(((p^2)^3)^2) ~ GF(p^12)
+// - field polynomial: g(w) = w^2 - vi => binominal with specific value of "vi"
+// - vi = 0*v^2 + 1*v + 0 - i.e vi={0,1,0} belongs to GF((p^2)^3)
+*/
+static BNU_CHUNK_T* cpGFpxMul_p2_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+
+ const BNU_CHUNK_T* pB0 = pB;
+ const BNU_CHUNK_T* pB1 = pB+groundElemLen;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(4, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* t2 = t1+groundElemLen;
+ BNU_CHUNK_T* t3 = t2+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
+ mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
+ addF(t2, pA0, pA1, pGroundGFE); /* t2 = a[0]+a[1] */
+ addF(t3, pB0, pB1, pGroundGFE); /* t3 = b[0]+b[1] */
+
+ mulF(pR1, t2, t3, pGroundGFE); /* r[1] = (a[0]+a[1]) * (b[0]+b[1]) */
+ subF(pR1, pR1, t0, pGroundGFE); /* r[1] -= a[0]*b[0]) + a[1]*b[1] */
+ subF(pR1, pR1, t1, pGroundGFE);
+
+ /* Intel(R) EPID 2.0 specific */
+ {
+ int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
+
+ /* deal with GF(p^2) */
+ if(basicExtDegree==2) {
+ subF(pR0, t0, t1, pGroundGFE);
+ }
+ /* deal with GF(p^6^2) */
+ else if(basicExtDegree==12) {
+ cpFq6Mul_vi(t1, t1, pGroundGFE);
+ addF(pR0, t0, t1, pGroundGFE);
+ }
+ /* deal with GF(p^x^2) - it's not Intel(R) EPID 2.0 case, just a case */
+ else {
+ cpGFpxMul_G0(t1, t1, pGFEx);
+ subF(pR0, t0, t1, pGroundGFE);
+ }
+ }
+
+ cpGFpReleasePool(4, pGroundGFE);
+ return pR;
+}
+
+/*
+// Intel(R) EPID 2.0 specific
+// ~~~~~~~~~~~~~~~
+//
+// Squaring over GF(p^2)
+// - field polynomial: g(x) = x^2 - beta => binominal with specific value of "beta"
+// - beta = p-1
+//
+// Squaring in GF(((p^2)^3)^2) ~ GF(p^12)
+// - field polynomial: g(w) = w^2 - vi => binominal with specific value of "vi"
+// - vi = 0*v^2 + 1*v + 0 - i.e vi={0,1,0} belongs to GF((p^2)^3)
+*/
+static BNU_CHUNK_T* cpGFpxSqr_p2_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+ mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
+ mod_add addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+groundElemLen;
+
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+groundElemLen;
+
+ BNU_CHUNK_T* t0 = cpGFpGetPool(3, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+groundElemLen;
+ BNU_CHUNK_T* u0 = t1+groundElemLen;
+ //tbcd: temporary excluded: assert(NULL!=t0);
+
+ mulF(u0, pA0, pA1, pGroundGFE); /* u0 = a[0]*a[1] */
+
+ /* Intel(R) EPID 2.0 specific */
+ {
+ int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
+
+ /* deal with GF(p^2) */
+ if(basicExtDegree==2) {
+ addF(t0, pA0, pA1, pGroundGFE);
+ subF(t1, pA0, pA1, pGroundGFE);
+ mulF(pR0, t0, t1, pGroundGFE);
+ addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
+ }
+ /* deal with GF(p^6^2) */
+ else if(basicExtDegree==12) {
+ subF(t0, pA0, pA1, pGroundGFE);
+ cpFq6Mul_vi(t1, pA1, pGroundGFE);
+ subF(t1, pA0, t1, pGroundGFE);
+ mulF(t0, t0, t1, pGroundGFE);
+ addF(t0, t0, u0, pGroundGFE);
+ cpFq6Mul_vi(t1, u0, pGroundGFE);
+ addF(pR0, t0, t1, pGroundGFE);
+ addF(pR1, u0, u0, pGroundGFE);
+ }
+ /* just a case */
+ else {
+ sqrF(t0, pA0, pGroundGFE); /* t0 = a[0]*a[0] */
+ sqrF(t1, pA1, pGroundGFE); /* t1 = a[1]*a[1] */
+ cpGFpxMul_G0(t1, t1, pGFEx);
+ subF(pR0, t0, t1, pGroundGFE);
+ addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
+ }
+ }
+
+ cpGFpReleasePool(3, pGroundGFE);
+ return pR;
+}
+
+/*
+// return specific polynomi alarith methods
+// polynomial - deg 2 binomial (Intel(R) EPID 2.0)
+*/
+static gsModMethod* gsPolyArith_binom2_epid2(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_p2_binom_epid2,
+ cpGFpxSqr_p2_binom_epid2,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom2_epid2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(x) = x^2 - a0, a0 from GF(q), a0 = 1
+// g(w) = w^2 - V0, v0 from GF((q^2)^3), V0 = 0*s^2 + v + 0
+//
+//
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom2_epid2, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Binom2_epid20,
+ 2,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith_binom2_epid2();
+ return &method;
+}
+
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.h b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.h
new file mode 100644
index 0000000..723cab4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_epid2.h
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// internal functions for GF(p^d) methods, if binomial generator
+// with Intel(R) Enhanced Privacy ID (Intel(R) EPID) 2.0 specific
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*
+// Intel(R) EPID 2.0 specific.
+//
+// Intel(R) EPID 2.0 uses the following finite field hierarchy:
+//
+// 1) prime field GF(p),
+// p = 0xFFFFFFFFFFFCF0CD46E5F25EEE71A49F0CDC65FB12980A82D3292DDBAED33013
+//
+// 2) 2-degree extension of GF(p): GF(p^2) == GF(p)[x]/g(x), g(x) = x^2 -beta,
+// beta =-1 mod p, so "beta" represents as {1}
+//
+// 3) 3-degree extension of GF(p^2) ~ GF(p^6): GF((p^2)^3) == GF(p)[v]/g(v), g(v) = v^3 -xi,
+// xi belongs GF(p^2), xi=x+2, so "xi" represents as {2,1} ---- "2" is low- and "1" is high-order coefficients
+//
+// 4) 2-degree extension of GF((p^2)^3) ~ GF(p^12): GF(((p^2)^3)^2) == GF(p)[w]/g(w), g(w) = w^2 -vi,
+// psi belongs GF((p^2)^3), vi=0*v^2 +1*v +0, so "vi" represents as {0,1,0}---- "0", '1" and "0" are low-, middle- and high-order coefficients
+//
+// See representations in t_gfpparam.cpp
+//
+*/
+
+/*
+// Multiplication case: mul(a, xi) over GF(p^2),
+// where:
+// a, belongs to GF(p^2)
+// xi belongs to GF(p^2), xi={2,1}
+//
+// The case is important in GF((p^2)^3) arithmetic for Intel(R) EPID 2.0.
+//
+*/
+__INLINE BNU_CHUNK_T* cpFq2Mul_xi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul addF = GFP_METHOD(pGroundGFE)->add;
+ mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
+
+ int termLen = GFP_FELEN(pGroundGFE);
+ BNU_CHUNK_T* t0 = cpGFpGetPool(2, pGroundGFE);
+ BNU_CHUNK_T* t1 = t0+termLen;
+
+ const BNU_CHUNK_T* pA0 = pA;
+ const BNU_CHUNK_T* pA1 = pA+termLen;
+ BNU_CHUNK_T* pR0 = pR;
+ BNU_CHUNK_T* pR1 = pR+termLen;
+
+ //tbcd: temporary excluded: assert(NULL!=t0);
+ addF(t0, pA0, pA0, pGroundGFE);
+ addF(t1, pA0, pA1, pGroundGFE);
+ subF(pR0, t0, pA1, pGroundGFE);
+ addF(pR1, t1, pA1, pGroundGFE);
+
+ cpGFpReleasePool(2, pGroundGFE);
+ return pR;
+}
+
+/*
+// Multiplication case: mul(a, g0) over GF(()),
+// where:
+// a and g0 belongs to GF(()) - field is being extension
+//
+// The case is important in GF(()^d) arithmetic if constructed polynomial is generic binomial g(t) = t^d +g0.
+//
+*/
+static BNU_CHUNK_T* cpGFpxMul_G0(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx); /* g(x) = t^d + g0 */
+ return GFP_METHOD(pGroundGFE)->mul(pR, pA, pGFpolynomial, pGroundGFE);
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_mulc.h b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_mulc.h
new file mode 100644
index 0000000..15cf1e3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_binom_mulc.h
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods, if binomial generator
+//
+*/
+#if !defined(_CP_GFP_METHOD_BINOM_H)
+#define _CP_GFP_METHOD_BINOM_H
+
+#include "owncp.h"
+#include "pcpgfpxstuff.h"
+
+
+static BNU_CHUNK_T* cpGFpxMul_G0(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
+
+ BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx); /* g(x) = t^d + g0 */
+
+ #if defined GS_DBG
+ BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
+ BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+ #endif
+
+ #if defined GS_DBG
+ cpGFpxGet(arg0, groundElemLen, pA, pGroundGFE);
+ cpGFpxGet(arg1, groundElemLen, pGFpolynomial, pGroundGFE);
+ #endif
+
+ mulF(pR, pA, pGFpolynomial, pGroundGFE);
+
+ #if defined GS_DBG
+ cpGFpReleasePool(2, pGroundGFE);
+ #endif
+
+ return pR;
+}
+
+#endif /* _CP_GFP_METHOD_BINOM_H */
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com.c
new file mode 100644
index 0000000..2917124
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com.c
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+/*
+// return common polynomi alarith methods
+*/
+static gsModMethod* gsPolyArith(void)
+{
+ static gsModMethod m = {
+ cpGFpxEncode_com,
+ cpGFpxDecode_com,
+ cpGFpxMul_com,
+ cpGFpxSqr_com,
+ NULL,
+ cpGFpxAdd_com,
+ cpGFpxSub_com,
+ cpGFpxNeg_com,
+ cpGFpxDiv2_com,
+ cpGFpxMul2_com,
+ cpGFpxMul3_com,
+ //cpGFpxInv
+ };
+ return &m;
+}
+
+/*F*
+// Name: ippsGFpxMethod_binom2
+//
+// Purpose: Returns a reference to the implementation of arithmetic operations over GF(pd).
+//
+// Returns: pointer to a structure containing
+// an implementation of arithmetic operations over GF(pd)
+// g(x) = x^d + x(d - 1) a_(d-1) + x^(d - 2)a_(d - 2) + ... + x1a1 + a0, ai from GF(p)
+//
+//
+*F*/
+
+IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_com, (void) )
+{
+ static IppsGFpMethod method = {
+ cpID_Poly,
+ 0,
+ NULL,
+ NULL
+ };
+ method.arith = gsPolyArith();
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com.h b/ext/ipp/sources/ippcp/pcpgfpxmethod_com.h
new file mode 100644
index 0000000..25e05ee
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com.h
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#if !defined(_CP_GFP_METHOD_COM_H)
+#define _CP_GFP_METHOD_COM_H
+
+#include "owncp.h"
+#include "pcpgfpstuff.h"
+
+#define cpGFpxAdd_com OWNAPI(cpGFpxAdd_com)
+BNU_CHUNK_T* cpGFpxAdd_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
+#define cpGFpxSub_com OWNAPI(cpGFpxSub_com)
+BNU_CHUNK_T* cpGFpxSub_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
+#define cpGFpxNeg_com OWNAPI(cpGFpxNeg_com)
+BNU_CHUNK_T* cpGFpxNeg_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+
+#define cpGFpxMul_com OWNAPI(cpGFpxMul_com)
+BNU_CHUNK_T* cpGFpxMul_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
+#define cpGFpxSqr_com OWNAPI(cpGFpxSqr_com)
+BNU_CHUNK_T* cpGFpxSqr_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+
+#define cpGFpxDiv2_com OWNAPI(cpGFpxDiv2_com)
+BNU_CHUNK_T* cpGFpxDiv2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+#define cpGFpxMul2_com OWNAPI(cpGFpxMul2_com)
+BNU_CHUNK_T* cpGFpxMul2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+#define cpGFpxMul3_com OWNAPI(cpGFpxMul3_com)
+BNU_CHUNK_T* cpGFpxMul3_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+
+#define cpGFpxEncode_com OWNAPI(cpGFpxEncode_com)
+BNU_CHUNK_T* cpGFpxEncode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+#define cpGFpxDecode_com OWNAPI(cpGFpxDecode_com)
+BNU_CHUNK_T* cpGFpxDecode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
+
+#endif /* _CP_GFP_METHOD_COM_H */
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_add.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_add.c
new file mode 100644
index 0000000..f08dc60
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_add.c
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxAdd_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_add addF = GFP_METHOD(pBasicGFE)->add;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ addF(pTmp, pA, pB, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ pB += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_decode.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_decode.c
new file mode 100644
index 0000000..3aaadb0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_decode.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxDecode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_decode decodeF = GFP_METHOD(pBasicGFE)->decode;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ decodeF(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_div2.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_div2.c
new file mode 100644
index 0000000..7d9c0c7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_div2.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxDiv2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_div2 div2F = GFP_METHOD(pBasicGFE)->div2;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ div2F(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_encode.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_encode.c
new file mode 100644
index 0000000..9b0e9f0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_encode.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxEncode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_encode encodeF = GFP_METHOD(pBasicGFE)->encode;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ encodeF(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul.c
new file mode 100644
index 0000000..2f2c8a4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpxMul_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ int extDegree = GFP_EXTDEGREE(pGFEx);
+
+ BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
+ int degR = extDegree-1;
+ int elemLen= GFP_FELEN(pGFEx);
+
+ int degB = degR;
+ BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFEx);
+ BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFEx);
+
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGFE);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ const BNU_CHUNK_T* pTmpB = GFPX_IDX_ELEMENT(pB, degB, groundElemLen);
+
+ //tbcd: temporary excluded: assert(NULL!=pTmpProduct && NULL!=r);
+
+ /* clear temporary */
+ cpGFpElementPadd(pTmpProduct, elemLen, 0);
+
+ /* R = A * B[degB-1] */
+ cpGFpxMul_GFE(pTmpResult, pA, pTmpB, pGFEx);
+
+ for(degB-=1; degB>=0; degB--) {
+ /* save R[degR-1] */
+ cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen);
+
+ { /* R = R * x */
+ int j;
+ for (j=degR; j>=1; j--)
+ cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen);
+ cpGFpElementPadd(pTmpResult, groundElemLen, 0);
+ }
+
+ cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFEx);
+ GFP_METHOD(pGFEx)->sub(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
+
+ /* B[degB-i] */
+ pTmpB -= groundElemLen;
+ cpGFpxMul_GFE(pTmpProduct, pA, pTmpB, pGFEx);
+ GFP_METHOD(pGFEx)->add(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
+ }
+
+ /* copy result */
+ cpGFpElementCopy(pR, pTmpResult, elemLen);
+
+ /* release pools */
+ cpGFpReleasePool(1, pGroundGFE);
+ cpGFpReleasePool(2, pGFEx);
+
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul2.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul2.c
new file mode 100644
index 0000000..c59d4a2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul2.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxMul2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_mul2 mul2F = GFP_METHOD(pBasicGFE)->mul2;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ mul2F(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul3.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul3.c
new file mode 100644
index 0000000..e0f1711
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_mul3.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxMul3_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_mul3 mul3F = GFP_METHOD(pBasicGFE)->mul3;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ mul3F(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_neg.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_neg.c
new file mode 100644
index 0000000..d8ab4ed
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_neg.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxNeg_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_neg negF = GFP_METHOD(pBasicGFE)->neg;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ negF(pTmp, pA, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sqr.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sqr.c
new file mode 100644
index 0000000..ae5ba25
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sqr.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+BNU_CHUNK_T* cpGFpxSqr_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
+{
+ int extDegree = GFP_EXTDEGREE(pGFEx);
+
+ BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
+ int degR = extDegree-1;
+ int elemLen= GFP_FELEN(pGFEx);
+
+ int degA = degR;
+ BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFEx);
+ BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFEx);
+
+ gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
+ BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGFE);
+ int groundElemLen = GFP_FELEN(pGroundGFE);
+
+ const BNU_CHUNK_T* pTmpA = GFPX_IDX_ELEMENT(pA, degA, groundElemLen);
+
+ //tbcd: temporary excluded: assert(NULL!=pTmpProduct && NULL!=r);
+
+ /* clear temporary */
+ cpGFpElementPadd(pTmpProduct, elemLen, 0);
+
+ /* R = A * A[degA-1] */
+ cpGFpxMul_GFE(pTmpResult, pA, pTmpA, pGFEx);
+
+ for(degA-=1; degA>=0; degA--) {
+ /* save R[degR-1] */
+ cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen);
+
+ { /* R = R * x */
+ int j;
+ for (j=degR; j>=1; j--)
+ cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen);
+ cpGFpElementPadd(pTmpResult, groundElemLen, 0);
+ }
+
+ cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFEx);
+ GFP_METHOD(pGFEx)->sub(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
+
+ /* A[degA-i] */
+ pTmpA -= groundElemLen;
+ cpGFpxMul_GFE(pTmpProduct, pA, pTmpA, pGFEx);
+ GFP_METHOD(pGFEx)->add(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
+ }
+
+ /* copy result */
+ cpGFpElementCopy(pR, pTmpResult, elemLen);
+
+ /* release pools */
+ cpGFpReleasePool(1, pGroundGFE);
+ cpGFpReleasePool(2, pGFEx);
+
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sub.c b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sub.c
new file mode 100644
index 0000000..daf905c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxmethod_com_sub.c
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// GF(p^d) methods
+//
+*/
+#include "owncp.h"
+
+#include "pcpgfpxstuff.h"
+#include "pcpgfpxmethod_com.h"
+
+
+BNU_CHUNK_T* cpGFpxSub_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
+{
+ gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
+ mod_sub subF = GFP_METHOD(pBasicGFE)->sub;
+ int basicElemLen = GFP_FELEN(pBasicGFE);
+ int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
+
+ BNU_CHUNK_T* pTmp = pR;
+ int deg;
+ for(deg=0; deg<basicDeg; deg++) {
+ subF(pTmp, pA, pB, pBasicGFE);
+ pTmp += basicElemLen;
+ pA += basicElemLen;
+ pB += basicElemLen;
+ }
+ return pR;
+}
diff --git a/ext/ipp/sources/ippcp/pcpgfpxstuff.c b/ext/ipp/sources/ippcp/pcpgfpxstuff.c
new file mode 100644
index 0000000..ecb4cfe
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpgfpxstuff.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+// Internal operations over GF(p) extension.
+//
+// Context:
+// cpGFpGetOptimalWinSize()
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnumisc.h"
+#include "pcpgfpxstuff.h"
+#include "gsscramble.h"
+
+static int div_upper(int a, int d)
+{ return (a+d-1)/d; }
+
+static int getNumOperations(int bitsize, int w)
+{
+ int n_overhead = (1<<w) -1;
+ int n_ops = div_upper(bitsize, w) + n_overhead;
+ return n_ops;
+}
+
+int cpGFpGetOptimalWinSize(int bitsize)
+{
+ int w_opt = 1;
+ int n_opt = getNumOperations(bitsize, w_opt);
+ int w_trial;
+ for(w_trial=w_opt+1; w_trial<=IPP_MAX_EXPONENT_NUM; w_trial++) {
+ int n_trial = getNumOperations(bitsize, w_trial);
+ if(n_trial>=n_opt) break;
+ w_opt = w_trial;
+ n_opt = n_trial;
+ }
+ return w_opt;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxstuff.h b/ext/ipp/sources/ippcp/pcpgfpxstuff.h
index 7477471..9a5525f 100644
--- a/ext/ipp/sources/ippcp/src/pcpgfpxstuff.h
+++ b/ext/ipp/sources/ippcp/pcpgfpxstuff.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Intel(R) Integrated Performance Primitives
@@ -158,4 +182,7 @@ BNU_CHUNK_T* cpGFpxInv (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGF
#define cpGFpxHalve OWNAPI(cpGFpxHalve)
BNU_CHUNK_T* cpGFpxHalve (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx);
+#define InitGFpxCtx OWNAPI(InitGFpxCtx)
+void InitGFpxCtx(const IppsGFpState* pGroundGF, int extDeg, const IppsGFpMethod* method, IppsGFpState* pGFpx);
+
#endif /* _PCP_GFPEXT_H_ */
diff --git a/ext/ipp/sources/ippcp/src/pcphash.h b/ext/ipp/sources/ippcp/pcphash.h
index a4650ec..950e56c 100644
--- a/ext/ipp/sources/ippcp/src/pcphash.h
+++ b/ext/ipp/sources/ippcp/pcphash.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -169,7 +193,6 @@ extern __ALIGN16 const Ipp64u SHA512_cnt[];
extern __ALIGN16 const Ipp32u MD5_cnt[];
extern __ALIGN16 const Ipp32u SM3_cnt[];
-
/* hash alg opt argument */
extern const void* cpHashProcFuncOpt[];
@@ -202,6 +225,9 @@ __INLINE IppHashAlgId cpValidHashAlg(IppHashAlgId algID)
return cpEnabledHashAlgID[algID];
}
+/* common functions */
+#define cpComputeDigest OWNAPI(cpComputeDigest)
+void cpComputeDigest(Ipp8u* pHashTag, int hashTagLen, const IppsHashState* pCtx);
/* processing functions */
#define UpdateSHA1 OWNAPI(UpdateSHA1)
@@ -223,6 +249,8 @@ void UpdateSHA256ni(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam
#endif
/* general methods */
+#define cpInitHash OWNAPI(cpInitHash)
+int cpInitHash(IppsHashState* pCtx, IppHashAlgId algID);
#define cpReInitHash OWNAPI(cpReInitHash)
int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID);
diff --git a/ext/ipp/sources/ippcp/pcphash_digest.c b/ext/ipp/sources/ippcp/pcphash_digest.c
new file mode 100644
index 0000000..a0115f2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphash_digest.c
@@ -0,0 +1,149 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// cpComputeDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+
+void cpComputeDigest(Ipp8u* pHashTag, int hashTagLen, const IppsHashState* pCtx)
+{
+ /* hash alg and parameters */
+ cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */
+ const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */
+
+ /* attributes */
+ const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)];
+ int mbs = pAttr->msgBlkSize; /* data block size */
+ int ivSize = pAttr->ivSize; /* size of hash's IV */
+ int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
+
+ /* number of bytes in context buffer */
+ int n = HAHS_BUFFIDX(pCtx);
+ /* buffer and it actual length */
+ Ipp8u buffer[MBS_HASH_MAX*2];
+ int bufferLen = n < (mbs-msgLenRepSize)? mbs : mbs*2;
+
+ /* copy current hash value */
+ cpHash hash;
+ CopyBlock(HASH_VALUE(pCtx), hash, ivSize);
+
+ /* copy of state's buffer */
+ CopyBlock(HASH_BUFF(pCtx), buffer, n);
+ /* end of message bit */
+ buffer[n++] = 0x80;
+ /* padd buffer */
+ PaddBlock(0, buffer+n, bufferLen-n-msgLenRepSize);
+
+ /* message length representation in bits (remember about big endian) */
+ {
+ /* convert processed message length bytes ->bits */
+ Ipp64u lo = HASH_LENLO(pCtx);
+ Ipp64u hi = HASH_LENHI(pCtx);
+ hi = LSL64(hi,3) | LSR64(lo,63-3);
+ lo = LSL64(lo,3);
+
+ if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ ((Ipp64u*)(buffer+bufferLen))[-2] = hi;
+ #else
+ ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(hi);
+ #endif
+ }
+
+ /* recall about MD5 specific */
+ if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
+ #else
+ ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
+ #endif
+ }
+ else {
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
+ #else
+ ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
+ #endif
+ }
+ }
+
+ /* copmplete hash computation */
+ hashFunc(hash, buffer, bufferLen, pParam);
+
+ /* store digest into the user buffer (remember digest in big endian) */
+ if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
+ /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
+ hash[0] = ENDIANNESS64(hash[0]);
+ hash[1] = ENDIANNESS64(hash[1]);
+ hash[2] = ENDIANNESS64(hash[2]);
+ hash[3] = ENDIANNESS64(hash[3]);
+ hash[4] = ENDIANNESS64(hash[4]);
+ hash[5] = ENDIANNESS64(hash[5]);
+ hash[6] = ENDIANNESS64(hash[6]);
+ hash[7] = ENDIANNESS64(hash[7]);
+ }
+ else if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
+ ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
+ ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
+ ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
+ ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
+ ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
+ if(ippHashAlg_SHA1!=HASH_ALG_ID(pCtx)) {
+ ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
+ ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
+ ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
+ }
+ }
+ CopyBlock(hash, pHashTag, hashTagLen);
+}
diff --git a/ext/ipp/sources/ippcp/pcphash_func.h b/ext/ipp/sources/ippcp/pcphash_func.h
new file mode 100644
index 0000000..9e7a688
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphash_func.h
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Internal Definitions and Internal Functions Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_HASH_FUNC_H)
+#define _PCP_HASH_FUNC_H
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+
+/*
+// hash alg default processing functions and opt argument
+*/
+static cpHashProc cpHashProcFunc[] = {
+ (cpHashProc)NULL,
+
+ #if defined(_ENABLE_ALG_SHA1_)
+ #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
+ UpdateSHA1ni,
+ #else
+ UpdateSHA1,
+ #endif
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA256_)
+ #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
+ UpdateSHA256ni,
+ #else
+ UpdateSHA256,
+ #endif
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA224_)
+ #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
+ UpdateSHA256ni,
+ #else
+ UpdateSHA256,
+ #endif
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA512_)
+ UpdateSHA512,
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA384_)
+ UpdateSHA512,
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_MD5_)
+ UpdateMD5,
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SM3_)
+ UpdateSM3,
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA512_224_)
+ UpdateSHA512,
+ #else
+ NULL,
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA512_256_)
+ UpdateSHA512,
+ #else
+ NULL,
+ #endif
+
+ NULL,
+};
+
+#endif /* _PCP_HASH_FUNC_H */
diff --git a/ext/ipp/sources/ippcp/pcphash_init.c b/ext/ipp/sources/ippcp/pcphash_init.c
new file mode 100644
index 0000000..dff04b5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphash_init.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// cpInitHash()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_func.h"
+#include "pcptool.h"
+
+int cpInitHash(IppsHashState* pCtx, IppHashAlgId algID)
+{
+ /* setup default processing function */
+ HASH_FUNC(pCtx) = cpHashProcFunc[algID];
+
+ /* update default processing function if SHA-NI enabled */
+ #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ if( IsFeatureEnabled(ippCPUID_SHA) ) {
+
+ #if defined(_ENABLE_ALG_SHA1_)
+ if(ippHashAlg_SHA1==algID)
+ HASH_FUNC(pCtx) = UpdateSHA1ni;
+ #endif
+
+ #if defined(_ENABLE_ALG_SHA256_) || defined(_ENABLE_ALG_SHA224_)
+ if(ippHashAlg_SHA256==algID || ippHashAlg_SHA224==algID)
+ HASH_FUNC(pCtx) = UpdateSHA256ni;
+ #endif
+ }
+ #endif
+
+ /* setup optional agr of processing function */
+ HASH_FUNC_PAR(pCtx) = cpHashProcFuncOpt[algID];
+
+ return cpReInitHash(pCtx, algID);
+}
diff --git a/ext/ipp/sources/ippcp/pcphash_reinit.c b/ext/ipp/sources/ippcp/pcphash_reinit.c
new file mode 100644
index 0000000..f502f23
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphash_reinit.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// cpReInitHash()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashInit
+//
+// Purpose: Init Hash state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNotSupportedModeErr if algID is not match to supported hash alg
+// ippStsNoErr no errors
+//
+// Parameters:
+// pCtx pointer to the Hash state
+// algID hash alg ID
+//
+*F*/
+int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID)
+{
+ int hashIvSize = cpHashIvSize(algID);
+ const Ipp8u* iv = cpHashIV[algID];
+
+ HASH_LENLO(pCtx) = CONST_64(0);
+ HASH_LENHI(pCtx) = CONST_64(0);
+ HAHS_BUFFIDX(pCtx) = 0;
+ CopyBlock(iv, HASH_VALUE(pCtx), hashIvSize);
+
+ return hashIvSize;
+}
diff --git a/ext/ipp/sources/ippcp/pcphash_rmf.h b/ext/ipp/sources/ippcp/pcphash_rmf.h
new file mode 100644
index 0000000..920c336
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphash_rmf.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Internal Definitions and Internal Functions Prototypes
+//
+*/
+
+#if !defined(_CP_HASH_RMF_H)
+#define _CP_HASH_RMF_H
+
+#include "pcphash.h"
+#include "pcphashmethod_rmf.h"
+
+struct _cpHashCtx_rmf {
+ IppCtxId idCtx; /* hash identifier */
+ const cpHashMethod_rmf* pMethod; /* hash methods */
+ int msgBuffIdx; /* buffer index */
+ Ipp8u msgBuffer[MBS_HASH_MAX]; /* buffer */
+ Ipp64u msgLenLo; /* processed message */
+ Ipp64u msgLenHi; /* length (bytes) */
+ cpHash msgHash; /* hash value */
+};
+
+/* accessors */
+#define HASH_CTX_ID(stt) ((stt)->idCtx)
+#define HASH_METHOD(stt) ((stt)->pMethod)
+#define HAHS_BUFFIDX(stt) ((stt)->msgBuffIdx)
+#define HASH_BUFF(stt) ((stt)->msgBuffer)
+#define HASH_LENLO(stt) ((stt)->msgLenLo)
+#define HASH_LENHI(stt) ((stt)->msgLenHi)
+#define HASH_VALUE(stt) ((stt)->msgHash)
+
+#define cpFinalize_rmf OWNAPI(cpFinalize_rmf)
+void cpFinalize_rmf(DigestSHA512 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u lenLo, Ipp64u lenHi, const IppsHashMethod* method);
+
+#endif /* _CP_HASH_RMF_H */
diff --git a/ext/ipp/sources/ippcp/pcphashca_rmf.c b/ext/ipp/sources/ippcp/pcphashca_rmf.c
new file mode 100644
index 0000000..0d9ca8d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashca_rmf.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// cpFinalize_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+void cpFinalize_rmf(DigestSHA512 pHash,
+ const Ipp8u* inpBuffer, int inpLen,
+ Ipp64u lenLo, Ipp64u lenHi,
+ const IppsHashMethod* method)
+{
+ int mbs = method->msgBlkSize; /* messge block size */
+ int mrl = method->msgLenRepSize; /* processed length representation size */
+
+ /* local buffer and it length */
+ Ipp8u buffer[MBS_SHA512*2];
+ int bufferLen = inpLen < (mbs-mrl)? mbs : mbs*2;
+
+ /* copy rest of message into internal buffer */
+ CopyBlock(inpBuffer, buffer, inpLen);
+
+ /* padd message */
+ buffer[inpLen++] = 0x80;
+ PaddBlock(0, buffer+inpLen, bufferLen-inpLen-mrl);
+
+ /* message length representation */
+ method->msgLenRep(buffer+bufferLen-mrl, lenLo, lenHi);
+
+ /* copmplete hash computation */
+ method->hashUpdate(pHash, buffer, bufferLen);
+}
diff --git a/ext/ipp/sources/ippcp/src/pcphashcnt.c b/ext/ipp/sources/ippcp/pcphashcnt.c
index 7762c1f..51d93e9 100644
--- a/ext/ipp/sources/ippcp/src/pcphashcnt.c
+++ b/ext/ipp/sources/ippcp/pcphashcnt.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/pcphashduplicate.c b/ext/ipp/sources/ippcp/pcphashduplicate.c
new file mode 100644
index 0000000..0bfd076
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashduplicate.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashDuplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashDuplicate
+//
+// Purpose: Clone Hash context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxHash
+// pDstState->idCtx != idCtxHash
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source Hash context
+// pDstState pointer to the target Hash context
+//
+// Note:
+// pDstState may to be uninitialized by ippsHashInit()
+//
+*F*/
+IPPFUN(IppStatus, ippsHashDuplicate,(const IppsHashState* pSrcState, IppsHashState* pDstState))
+{
+ /* test state pointers */
+ IPP_BAD_PTR2_RET(pSrcState, pDstState);
+ /* test states ID */
+ IPP_BADARG_RET(!HASH_VALID_ID(pSrcState), ippStsContextMatchErr);
+
+ /* copy state */
+ CopyBlock(pSrcState, pDstState, sizeof(IppsHashState));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashduplicate_rmf.c b/ext/ipp/sources/ippcp/pcphashduplicate_rmf.c
new file mode 100644
index 0000000..519c551
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashduplicate_rmf.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashDuplicate_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashDuplicate_rmf
+//
+// Purpose: Clone Hash context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxHash
+// pDstState->idCtx != idCtxHash
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source Hash context
+// pDstState pointer to the target Hash context
+//
+// Note:
+// pDstState may to be uninitialized by ippsHashInit_rmf()
+//
+*F*/
+IPPFUN(IppStatus, ippsHashDuplicate_rmf,(const IppsHashState_rmf* pSrcState, IppsHashState_rmf* pDstState))
+{
+ /* test state pointers */
+ IPP_BAD_PTR2_RET(pSrcState, pDstState);
+ pSrcState = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pSrcState, HASH_ALIGNMENT) );
+ pDstState = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pDstState, HASH_ALIGNMENT) );
+ /* test states ID */
+ IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pSrcState), ippStsContextMatchErr);
+
+ /* copy state */
+ CopyBlock(pSrcState, pDstState, sizeof(IppsHashState_rmf));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashfinal.c b/ext/ipp/sources/ippcp/pcphashfinal.c
new file mode 100644
index 0000000..8eb2d86
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashfinal.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashFinal()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsHashFinal
+//
+// Purpose: Complete message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR2_RET(pMD, pState);
+ /* test the context */
+ IPP_BADARG_RET(!HASH_VALID_ID(pState), ippStsContextMatchErr);
+
+ {
+ IppHashAlgId algID = HASH_ALG_ID(pState);
+ int hashSize = cpHashAlgAttr[algID].hashSize;
+
+ cpComputeDigest(pMD, hashSize, pState);
+ cpReInitHash(pState, algID);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashfinal_rmf.c b/ext/ipp/sources/ippcp/pcphashfinal_rmf.c
new file mode 100644
index 0000000..3dd41de
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashfinal_rmf.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashFinal_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsHashFinal_rmf
+//
+// Purpose: Complete message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashFinal_rmf,(Ipp8u* pMD, IppsHashState_rmf* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR2_RET(pMD, pState);
+ pState= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pState, HASH_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ {
+ const IppsHashMethod* method = HASH_METHOD(pState);
+
+ cpFinalize_rmf(HASH_VALUE(pState),
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState),
+ method);
+ /* convert hash into oct string */
+ method->hashOctStr(pMD, HASH_VALUE(pState));
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ HASH_LENHI(pState) = 0;
+ method->hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashgetsize.c b/ext/ipp/sources/ippcp/pcphashgetsize.c
new file mode 100644
index 0000000..e32db73
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashgetsize.c
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashGetSize
+//
+// Purpose: Returns size (bytes) of IppsHashState state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+IPPFUN(IppStatus, ippsHashGetSize,(int* pSize))
+{
+ /* test pointers */
+ IPP_BAD_PTR1_RET(pSize);
+
+ *pSize = sizeof(IppsHashState);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashgetsize_rmf.c b/ext/ipp/sources/ippcp/pcphashgetsize_rmf.c
new file mode 100644
index 0000000..5573497
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashgetsize_rmf.c
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashGetSize_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashGetSize_rmf
+//
+// Purpose: Returns size (bytes) of IppsHashState state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+IPPFUN(IppStatus, ippsHashGetSize_rmf,(int* pSize))
+{
+ /* test pointers */
+ IPP_BAD_PTR1_RET(pSize);
+
+ *pSize = sizeof(IppsHashState_rmf) +(HASH_ALIGNMENT-1);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashgettag.c b/ext/ipp/sources/ippcp/pcphashgettag.c
new file mode 100644
index 0000000..1893081
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashgettag.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashGetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashGetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsLengthErr hashSize < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashGetTag,(Ipp8u* pTag, int tagLen, const IppsHashState* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR2_RET(pTag, pState);
+ /* test the context */
+ IPP_BADARG_RET(!HASH_VALID_ID(pState), ippStsContextMatchErr);
+
+ {
+ /* size of hash */
+ int hashSize = cpHashAlgAttr[HASH_ALG_ID(pState)].hashSize;
+ if(tagLen<1||hashSize<tagLen) IPP_ERROR_RET(ippStsLengthErr);
+
+ cpComputeDigest(pTag, tagLen, pState);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashgettag_rmf.c b/ext/ipp/sources/ippcp/pcphashgettag_rmf.c
new file mode 100644
index 0000000..70155f5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashgettag_rmf.c
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashGetTag_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsHashGetTag_rmf
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsLengthErr hashSize < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashGetTag_rmf,(Ipp8u* pTag, int tagLen, const IppsHashState_rmf* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pState, HASH_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen <1) || HASH_METHOD(pState)->hashLen<tagLen, ippStsLengthErr);
+
+ { /* TBD: consider implementation without copy of internal buffer content */
+ DigestSHA512 hash;
+ const IppsHashMethod* method = HASH_METHOD(pState);
+ CopyBlock(HASH_VALUE(pState), hash, sizeof(DigestSHA512));
+ cpFinalize_rmf(hash,
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState),
+ method);
+ method->hashOctStr(pTag, hash);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashinit.c b/ext/ipp/sources/ippcp/pcphashinit.c
new file mode 100644
index 0000000..eabc16e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashinit.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashInit
+//
+// Purpose: Init Hash state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA1 state
+// hashAlg identifier of the hash algorithm
+//
+*F*/
+
+IPPFUN(IppStatus, ippsHashInit,(IppsHashState* pState, IppHashAlgId hashAlg))
+{
+ /* get algorithm id */
+ hashAlg = cpValidHashAlg(hashAlg);
+ /* test hash alg */
+ IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
+
+ /* test ctx pointer */
+ IPP_BAD_PTR1_RET(pState);
+ /* test hash alg */
+
+ /* set ctx ID */
+ HASH_CTX_ID(pState) = idCtxHash;
+ HASH_ALG_ID(pState) = hashAlg;
+
+ /* init context */
+ cpInitHash(pState, hashAlg);
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashinit_rmf.c b/ext/ipp/sources/ippcp/pcphashinit_rmf.c
new file mode 100644
index 0000000..7079c61
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashinit_rmf.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashInit_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashInit_rmf
+//
+// Purpose: Init Hash state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pMethod == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the Hash state
+// pMethod hash method
+//
+*F*/
+IPPFUN(IppStatus, ippsHashInit_rmf,(IppsHashState_rmf* pState, const IppsHashMethod* pMethod))
+{
+ /* test ctx pointers */
+ IPP_BAD_PTR2_RET(pState, pMethod);
+ pState= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pState, HASH_ALIGNMENT) );
+
+ PaddBlock(0, pState, sizeof(IppsHashState_rmf));
+ HASH_METHOD(pState) = pMethod;
+ HASH_CTX_ID(pState) = idCtxHash;
+ pMethod->hashInit(HASH_VALUE(pState));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmd5px.c b/ext/ipp/sources/ippcp/pcphashmd5px.c
new file mode 100644
index 0000000..dc103fe
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmd5px.c
@@ -0,0 +1,233 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Message block processing according to MD5
+//
+// Contents:
+// UpdateMD5()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+#if !defined(_ENABLE_ALG_MD5_)
+#pragma message("IPP_ALG_HASH_MD5 disabled")
+
+#else
+#pragma message("IPP_ALG_HASH_MD5 enabled")
+
+#if !((_IPP==_IPP_M5) || \
+ (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \
+ (_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
+
+
+/*
+// Magic functions defined in RFC 1321
+//
+*/
+#define F(X,Y,Z) ((Z) ^ ((X) & ((Y) ^ (Z)))) /* sightly optimized form of (((X) & (Y)) | ((~(X) & (Z)))*/
+#define G(X,Y,Z) F((Z),(X),(Y)) /* replace the original (((X) & (Z)) | ((Y) & ~(Z))) */
+#define H(X,Y,Z) ((X) ^ (Y) ^ (Z))
+#define I(X,Y,Z) ((Y) ^ ((X) | ~(Z)))
+
+/*
+// MD5 step
+*/
+#define MD5_STEP(MAGIC, A,B,C,D, data, constant, nrot) \
+ (A = B +ROL32((A +MAGIC(B,C,D) +data +constant), nrot))
+
+/*
+// MD5 left rotations (number of bits)
+// depends on round type
+*/
+#define F1 7
+#define F2 12
+#define F3 17
+#define F4 22
+
+#define G1 5
+#define G2 9
+#define G3 14
+#define G4 20
+
+#define H1 4
+#define H2 11
+#define H3 16
+#define H4 23
+
+#define I1 6
+#define I2 10
+#define I3 15
+#define I4 21
+
+/*F*
+// Name: UpdateMD5
+//
+// Purpose: Update internal hash according to input message stream.
+//
+// Parameters:
+// uniHash pointer to in/out hash
+// mblk pointer to message stream
+// mlen message stream length (multiple by message block size)
+// uniParam pointer to the optional parameter
+//
+*F*/
+void UpdateMD5(void* uinHash, const Ipp8u* mblk, int mlen, const void* uniParam)
+{
+ Ipp32u* digest = (Ipp32u*)uinHash;
+ Ipp32u* MD5_cnt_loc = (Ipp32u*)uniParam;
+
+ for(; mlen>=MBS_MD5; mblk += MBS_MD5, mlen -= MBS_MD5) {
+
+ /* allocate data */
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ Ipp32u data[MBS_MD5/sizeof(Ipp32u)];
+ #else
+ /* or just word alias */
+ Ipp32u* data = (Ipp32u*)mblk;
+ #endif
+
+ /* init variables */
+ Ipp32u a = digest[0];
+ Ipp32u b = digest[1];
+ Ipp32u c = digest[2];
+ Ipp32u d = digest[3];
+
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ int t;
+ for(t=0; t<16; t++) {
+ data[t] = ENDIANNESS(((Ipp32u*)mblk)[t]);
+ }
+ #endif
+
+ /* rounds type F */
+ MD5_STEP(F, a,b,c,d, data[ 0], MD5_cnt_loc[ 0], F1);
+ MD5_STEP(F, d,a,b,c, data[ 1], MD5_cnt_loc[ 1], F2);
+ MD5_STEP(F, c,d,a,b, data[ 2], MD5_cnt_loc[ 2], F3);
+ MD5_STEP(F, b,c,d,a, data[ 3], MD5_cnt_loc[ 3], F4);
+ MD5_STEP(F, a,b,c,d, data[ 4], MD5_cnt_loc[ 4], F1);
+ MD5_STEP(F, d,a,b,c, data[ 5], MD5_cnt_loc[ 5], F2);
+ MD5_STEP(F, c,d,a,b, data[ 6], MD5_cnt_loc[ 6], F3);
+ MD5_STEP(F, b,c,d,a, data[ 7], MD5_cnt_loc[ 7], F4);
+ MD5_STEP(F, a,b,c,d, data[ 8], MD5_cnt_loc[ 8], F1);
+ MD5_STEP(F, d,a,b,c, data[ 9], MD5_cnt_loc[ 9], F2);
+ MD5_STEP(F, c,d,a,b, data[10], MD5_cnt_loc[10], F3);
+ MD5_STEP(F, b,c,d,a, data[11], MD5_cnt_loc[11], F4);
+ MD5_STEP(F, a,b,c,d, data[12], MD5_cnt_loc[12], F1);
+ MD5_STEP(F, d,a,b,c, data[13], MD5_cnt_loc[13], F2);
+ MD5_STEP(F, c,d,a,b, data[14], MD5_cnt_loc[14], F3);
+ MD5_STEP(F, b,c,d,a, data[15], MD5_cnt_loc[15], F4);
+
+ /* rounds type G */
+ MD5_STEP(G, a,b,c,d, data[ 1], MD5_cnt_loc[16], G1);
+ MD5_STEP(G, d,a,b,c, data[ 6], MD5_cnt_loc[17], G2);
+ MD5_STEP(G, c,d,a,b, data[11], MD5_cnt_loc[18], G3);
+ MD5_STEP(G, b,c,d,a, data[ 0], MD5_cnt_loc[19], G4);
+ MD5_STEP(G, a,b,c,d, data[ 5], MD5_cnt_loc[20], G1);
+ MD5_STEP(G, d,a,b,c, data[10], MD5_cnt_loc[21], G2);
+ MD5_STEP(G, c,d,a,b, data[15], MD5_cnt_loc[22], G3);
+ MD5_STEP(G, b,c,d,a, data[ 4], MD5_cnt_loc[23], G4);
+ MD5_STEP(G, a,b,c,d, data[ 9], MD5_cnt_loc[24], G1);
+ MD5_STEP(G, d,a,b,c, data[14], MD5_cnt_loc[25], G2);
+ MD5_STEP(G, c,d,a,b, data[ 3], MD5_cnt_loc[26], G3);
+ MD5_STEP(G, b,c,d,a, data[ 8], MD5_cnt_loc[27], G4);
+ MD5_STEP(G, a,b,c,d, data[13], MD5_cnt_loc[28], G1);
+ MD5_STEP(G, d,a,b,c, data[ 2], MD5_cnt_loc[29], G2);
+ MD5_STEP(G, c,d,a,b, data[ 7], MD5_cnt_loc[30], G3);
+ MD5_STEP(G, b,c,d,a, data[12], MD5_cnt_loc[31], G4);
+
+ /* rounds type H */
+ MD5_STEP(H, a,b,c,d, data[ 5], MD5_cnt_loc[32], H1);
+ MD5_STEP(H, d,a,b,c, data[ 8], MD5_cnt_loc[33], H2);
+ MD5_STEP(H, c,d,a,b, data[11], MD5_cnt_loc[34], H3);
+ MD5_STEP(H, b,c,d,a, data[14], MD5_cnt_loc[35], H4);
+ MD5_STEP(H, a,b,c,d, data[ 1], MD5_cnt_loc[36], H1);
+ MD5_STEP(H, d,a,b,c, data[ 4], MD5_cnt_loc[37], H2);
+ MD5_STEP(H, c,d,a,b, data[ 7], MD5_cnt_loc[38], H3);
+ MD5_STEP(H, b,c,d,a, data[10], MD5_cnt_loc[39], H4);
+ MD5_STEP(H, a,b,c,d, data[13], MD5_cnt_loc[40], H1);
+ MD5_STEP(H, d,a,b,c, data[ 0], MD5_cnt_loc[41], H2);
+ MD5_STEP(H, c,d,a,b, data[ 3], MD5_cnt_loc[42], H3);
+ MD5_STEP(H, b,c,d,a, data[ 6], MD5_cnt_loc[43], H4);
+ MD5_STEP(H, a,b,c,d, data[ 9], MD5_cnt_loc[44], H1);
+ MD5_STEP(H, d,a,b,c, data[12], MD5_cnt_loc[45], H2);
+ MD5_STEP(H, c,d,a,b, data[15], MD5_cnt_loc[46], H3);
+ MD5_STEP(H, b,c,d,a, data[ 2], MD5_cnt_loc[47], H4);
+
+ /* rounds type I */
+ MD5_STEP(I, a,b,c,d, data[ 0], MD5_cnt_loc[48], I1);
+ MD5_STEP(I, d,a,b,c, data[ 7], MD5_cnt_loc[49], I2);
+ MD5_STEP(I, c,d,a,b, data[14], MD5_cnt_loc[50], I3);
+ MD5_STEP(I, b,c,d,a, data[ 5], MD5_cnt_loc[51], I4);
+ MD5_STEP(I, a,b,c,d, data[12], MD5_cnt_loc[52], I1);
+ MD5_STEP(I, d,a,b,c, data[ 3], MD5_cnt_loc[53], I2);
+ MD5_STEP(I, c,d,a,b, data[10], MD5_cnt_loc[54], I3);
+ MD5_STEP(I, b,c,d,a, data[ 1], MD5_cnt_loc[55], I4);
+ MD5_STEP(I, a,b,c,d, data[ 8], MD5_cnt_loc[56], I1);
+ MD5_STEP(I, d,a,b,c, data[15], MD5_cnt_loc[57], I2);
+ MD5_STEP(I, c,d,a,b, data[ 6], MD5_cnt_loc[58], I3);
+ MD5_STEP(I, b,c,d,a, data[13], MD5_cnt_loc[59], I4);
+ MD5_STEP(I, a,b,c,d, data[ 4], MD5_cnt_loc[60], I1);
+ MD5_STEP(I, d,a,b,c, data[11], MD5_cnt_loc[61], I2);
+ MD5_STEP(I, c,d,a,b, data[ 2], MD5_cnt_loc[62], I3);
+ MD5_STEP(I, b,c,d,a, data[ 9], MD5_cnt_loc[63], I4);
+
+ /* update digest */
+ digest[0] += a;
+ digest[1] += b;
+ digest[2] += c;
+ digest[3] += d;
+ }
+}
+
+#endif
+#endif /* IPP_ALG_HASH_MD5 */
diff --git a/ext/ipp/sources/ippcp/pcphashmessage.c b/ext/ipp/sources/ippcp/pcphashmessage.c
new file mode 100644
index 0000000..7e270be
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmessage.c
@@ -0,0 +1,168 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashMessage()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_func.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashMessage
+//
+// Purpose: Hash of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pMsg == NULL but len!=0
+// ippStsLengthErr len <0
+// ippStsNotSupportedModeErr if hashAlg is not match to supported hash alg
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+// hashAlg hash alg ID
+//
+*F*/
+IPPFUN(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int len, Ipp8u* pMD, IppHashAlgId hashAlg))
+{
+ /* get algorithm id */
+ hashAlg = cpValidHashAlg(hashAlg);
+ /* test hash alg */
+ IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+ /* test message length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((len && !pMsg), ippStsNullPtrErr);
+
+ {
+ /* processing function and parameter */
+ cpHashProc hashFunc = cpHashProcFunc[hashAlg];
+ const void* pParam = cpHashProcFuncOpt[hashAlg];
+
+ /* attributes */
+ const cpHashAttr* pAttr = &cpHashAlgAttr[hashAlg];
+ int mbs = pAttr->msgBlkSize; /* data block size */
+ int ivSize = pAttr->ivSize; /* size of hash's IV */
+ int hashSize = pAttr->hashSize; /* hash size */
+ int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
+
+ /* message bitlength representation */
+ Ipp64u msgLenBits = (Ipp64u)len*8;
+ /* length of main message part */
+ int msgLenBlks = len & (-mbs);
+ /* rest of message length */
+ int msgLenRest = len - msgLenBlks;
+
+ /* end of message buffer */
+ Ipp8u buffer[MBS_HASH_MAX*2];
+ int bufferLen = (msgLenRest < (mbs-msgLenRepSize))? mbs : mbs*2;
+
+ /* init hash */
+ cpHash hash;
+ const Ipp8u* iv = cpHashIV[hashAlg];
+ CopyBlock(iv, hash, ivSize);
+
+ /*construct last messge block(s) */
+ #define MSG_LEN_REP (sizeof(Ipp64u))
+
+ /* copy end of message */
+ CopyBlock(pMsg+len-msgLenRest, buffer, msgLenRest);
+ /* end of message bit */
+ buffer[msgLenRest++] = 0x80;
+ /* padd buffer */
+ PaddBlock(0, buffer+msgLenRest, bufferLen-msgLenRest-MSG_LEN_REP);
+ /* copy message bitlength representation */
+ if(ippHashAlg_MD5!=hashAlg)
+ msgLenBits = ENDIANNESS64(msgLenBits);
+ ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits;
+
+ #undef MSG_LEN_REP
+
+ /* message processing */
+ if(msgLenBlks)
+ hashFunc(hash, pMsg, msgLenBlks, pParam);
+ hashFunc(hash, buffer, bufferLen, pParam);
+
+ /* store digest into the user buffer (remember digest in big endian) */
+ if(msgLenRepSize > (int)(sizeof(Ipp64u))) {
+ /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
+ hash[0] = ENDIANNESS64(hash[0]);
+ hash[1] = ENDIANNESS64(hash[1]);
+ hash[2] = ENDIANNESS64(hash[2]);
+ hash[3] = ENDIANNESS64(hash[3]);
+ hash[4] = ENDIANNESS64(hash[4]);
+ hash[5] = ENDIANNESS64(hash[5]);
+ hash[6] = ENDIANNESS64(hash[6]);
+ hash[7] = ENDIANNESS64(hash[7]);
+ }
+ else if(ippHashAlg_MD5!=hashAlg) {
+ /* ippHashAlg_SHA1, ippHashAlg_SHA224, ippHashAlg_SHA256 and ippHashAlg_SM3 */
+ ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
+ ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
+ ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
+ ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
+ ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
+ ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
+ ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
+ ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
+ }
+ CopyBlock(hash, pMD, hashSize);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmessage_rmf.c b/ext/ipp/sources/ippcp/pcphashmessage_rmf.c
new file mode 100644
index 0000000..ae7e60d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmessage_rmf.c
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashMessage_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashMessage_rmf
+//
+// Purpose: Hash of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pMsg == NULL but len!=0
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+// pMethod hash methods
+//
+*F*/
+IPPFUN(IppStatus, ippsHashMessage_rmf,(const Ipp8u* pMsg, int len, Ipp8u* pMD, const IppsHashMethod* pMethod))
+{
+ /* test method pointer */
+ IPP_BAD_PTR1_RET(pMethod);
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+ /* test message length */
+ IPP_BADARG_RET(0>len, ippStsLengthErr);
+ IPP_BADARG_RET((len && !pMsg), ippStsNullPtrErr);
+
+ {
+ /* message length in the multiple MBS and the rest */
+ int msgLenBlks = len &(-pMethod->msgBlkSize);
+ int msgLenRest = len - msgLenBlks;
+
+ /* init hash */
+ DigestSHA512 hash;
+ pMethod->hashInit(hash);
+
+ /* process main part of the message */
+ if(msgLenBlks) {
+ pMethod->hashUpdate(hash, pMsg, msgLenBlks);
+ pMsg += msgLenBlks;
+ }
+ cpFinalize_rmf(hash,
+ pMsg, msgLenRest,
+ len, 0,
+ pMethod);
+
+ pMethod->hashOctStr(pMD, hash);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_md5.c b/ext/ipp/sources/ippcp/pcphashmethod_md5.c
new file mode 100644
index 0000000..e90e747
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_md5.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to MD5
+// (derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm)
+//
+// Equivalent code is available from RFC 1321.
+//
+// Contents:
+// ippsHashMethod_MD5()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpmd5stuff.h"
+
+/*F*
+// Name: ippsHashMethod_MD5
+//
+// Purpose: Return MD5 method.
+//
+// Returns:
+// Pointer to MD5 hash-method.
+//
+*F*/
+IPPFUN( const IppsHashMethod*, ippsHashMethod_MD5, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_MD5,
+ IPP_MD5_DIGEST_BITSIZE/8,
+ MBS_MD5,
+ MLR_MD5,
+ md5_hashInit,
+ md5_hashUpdate,
+ md5_hashOctString,
+ md5_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_rmf.h b/ext/ipp/sources/ippcp/pcphashmethod_rmf.h
new file mode 100644
index 0000000..a41aaf4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_rmf.h
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Internal Definitions and Internal Functions Prototypes
+//
+*/
+#if !defined(_PCP_HASH_METHOD_RMF_H)
+#define _PCP_HASH_METHOD_RMF_H
+
+/* hash alg methods */
+typedef void (*hashInitF)(void* pHash);
+typedef void (*hashUpdateF)(void* pHash, const Ipp8u* pMsg, int msgLen);
+typedef void (*hashOctStrF)(Ipp8u* pDst, void* pHash);
+typedef void (*msgLenRepF)(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi);
+
+typedef struct _cpHashMethod_rmf {
+ IppHashAlgId hashAlgId; /* algorithm ID */
+ int hashLen; /* hash length in bytes */
+ int msgBlkSize; /* message blkock size in bytes */
+ int msgLenRepSize; /* length of processed msg length representation in bytes */
+ hashInitF hashInit; /* set initial hash value */
+ hashUpdateF hashUpdate; /* hash compressor */
+ hashOctStrF hashOctStr; /* convert hash into oct string */
+ msgLenRepF msgLenRep; /* processed mgs length representation */
+} cpHashMethod_rmf;
+
+#endif /* _PCP_HASH_METHOD_RMF_H */
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha1.c b/ext/ipp/sources/ippcp/pcphashmethod_sha1.c
new file mode 100644
index 0000000..068aafc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha1.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsHashMethod_SHA1()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA1
+//
+// Purpose: Return SHA1 method.
+//
+// Returns:
+// Pointer to SHA1 hash-method.
+//
+*F*/
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA1, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA1,
+ IPP_SHA1_DIGEST_BITSIZE/8,
+ MBS_SHA1,
+ MLR_SHA1,
+ sha1_hashInit,
+ sha1_hashUpdate,
+ sha1_hashOctString,
+ sha1_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha1_ni.c b/ext/ipp/sources/ippcp/pcphashmethod_sha1_ni.c
new file mode 100644
index 0000000..c364083
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha1_ni.c
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsHashMethod_SHA1_NI()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA1_NI
+//
+// Purpose: Return SHA1 method (using the SHA-NI instruction set).
+//
+// Returns:
+// Pointer to SHA1 hash-method (using the SHA-NI instruction set).
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA1_NI, (void) )
+{
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ static IppsHashMethod method = {
+ ippHashAlg_SHA1,
+ IPP_SHA1_DIGEST_BITSIZE/8,
+ MBS_SHA1,
+ MLR_SHA1,
+ sha1_hashInit,
+ sha1_ni_hashUpdate,
+ sha1_hashOctString,
+ sha1_msgRep
+ };
+ return &method;
+ #else
+ return NULL;
+ #endif
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha1_tt.c b/ext/ipp/sources/ippcp/pcphashmethod_sha1_tt.c
new file mode 100644
index 0000000..58e3ac7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha1_tt.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsHashMethod_SHA1_TT()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA1_TT
+//
+// Purpose: Return SHA1 method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+// Returns:
+// Pointer to SHA1 hash-method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA1_TT, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA1,
+ IPP_SHA1_DIGEST_BITSIZE/8,
+ MBS_SHA1,
+ MLR_SHA1,
+ sha1_hashInit,
+ sha1_hashUpdate,
+ sha1_hashOctString,
+ sha1_msgRep
+ };
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ if(IsFeatureEnabled(ippCPUID_SHA))
+ method.hashUpdate = sha1_ni_hashUpdate;
+ #endif
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha224.c b/ext/ipp/sources/ippcp/pcphashmethod_sha224.c
new file mode 100644
index 0000000..3149d20
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha224.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA224()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA224
+//
+// Purpose: Return SHA224 method.
+//
+// Returns:
+// Pointer to SHA224 hash-method.
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA224,
+ IPP_SHA224_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha224_hashInit,
+ sha256_hashUpdate,
+ sha224_hashOctString,
+ sha256_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha224_ni.c b/ext/ipp/sources/ippcp/pcphashmethod_sha224_ni.c
new file mode 100644
index 0000000..215ec84
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha224_ni.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA224_NI()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA224_NI
+//
+// Purpose: Return SHA224 method (using the SHA-NI instruction set).
+//
+// Returns:
+// Pointer to SHA224 hash-method (using the SHA-NI instruction set).
+//
+*F*/
+
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224_NI, (void) )
+{
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ static IppsHashMethod method = {
+ ippHashAlg_SHA224,
+ IPP_SHA224_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha224_hashInit,
+ sha256_ni_hashUpdate,
+ sha224_hashOctString,
+ sha256_msgRep
+ };
+ return &method;
+ #else
+ return NULL;
+ #endif
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha224_tt.c b/ext/ipp/sources/ippcp/pcphashmethod_sha224_tt.c
new file mode 100644
index 0000000..9f2463e
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha224_tt.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA224_TT()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA224_TT
+//
+// Purpose: Return SHA224 method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+// Returns:
+// Pointer to SHA224 hash-method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224_TT, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA224,
+ IPP_SHA224_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha224_hashInit,
+ sha256_hashUpdate,
+ sha224_hashOctString,
+ sha256_msgRep
+ };
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ if(IsFeatureEnabled(ippCPUID_SHA))
+ method.hashUpdate = sha256_ni_hashUpdate;
+ #endif
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha256.c b/ext/ipp/sources/ippcp/pcphashmethod_sha256.c
new file mode 100644
index 0000000..4964621
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha256.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA256()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA256
+//
+// Purpose: Return SHA256 method.
+//
+// Returns:
+// Pointer to SHA256 hash-method.
+//
+*F*/
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA256,
+ IPP_SHA256_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha256_hashInit,
+ sha256_hashUpdate,
+ sha256_hashOctString,
+ sha256_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha256_ni.c b/ext/ipp/sources/ippcp/pcphashmethod_sha256_ni.c
new file mode 100644
index 0000000..fbf8cfb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha256_ni.c
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA256_NI()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA256_NI
+//
+// Purpose: Return SHA256 method (using the SHA-NI instruction set).
+//
+// Returns:
+// Pointer to SHA256 hash-method (using the SHA-NI instruction set).
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256_NI, (void) )
+{
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ static IppsHashMethod method = {
+ ippHashAlg_SHA256,
+ IPP_SHA256_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha256_hashInit,
+ sha256_ni_hashUpdate,
+ sha256_hashOctString,
+ sha256_msgRep
+ };
+ return &method;
+ #else
+ return NULL;
+ #endif
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha256_tt.c b/ext/ipp/sources/ippcp/pcphashmethod_sha256_tt.c
new file mode 100644
index 0000000..d0a56da
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha256_tt.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsHashMethod_SHA256_TT()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA256_TT
+//
+// Purpose: Return SHA256 method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+// Returns:
+// Pointer to SHA256 hash-method
+// (using the SHA-NI instructions set
+// if it is available at run time)
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256_TT, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA256,
+ IPP_SHA256_DIGEST_BITSIZE/8,
+ MBS_SHA256,
+ MLR_SHA256,
+ sha256_hashInit,
+ sha256_hashUpdate,
+ sha256_hashOctString,
+ sha256_msgRep
+ };
+ #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+ if(IsFeatureEnabled(ippCPUID_SHA))
+ method.hashUpdate = sha256_ni_hashUpdate;
+ #endif
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha384.c b/ext/ipp/sources/ippcp/pcphashmethod_sha384.c
new file mode 100644
index 0000000..bbfdd0c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha384.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsHashMethod_SHA384()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA384
+//
+// Purpose: Return SHA384 method.
+//
+// Returns:
+// Pointer to SHA384 hash-method.
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA384, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA384,
+ IPP_SHA384_DIGEST_BITSIZE/8,
+ MBS_SHA512,
+ MLR_SHA512,
+ sha512_384_hashInit,
+ sha512_hashUpdate,
+ sha512_384_hashOctString,
+ sha512_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha512.c b/ext/ipp/sources/ippcp/pcphashmethod_sha512.c
new file mode 100644
index 0000000..18b8935
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha512.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsHashMethod_SHA512()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA512
+//
+// Purpose: Return SHA512 method.
+//
+// Returns:
+// Pointer to SHA512 hash-method.
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA512, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA512,
+ IPP_SHA512_DIGEST_BITSIZE/8,
+ MBS_SHA512,
+ MLR_SHA512,
+ sha512_hashInit,
+ sha512_hashUpdate,
+ sha512_hashOctString,
+ sha512_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha512_224.c b/ext/ipp/sources/ippcp/pcphashmethod_sha512_224.c
new file mode 100644
index 0000000..29bbffc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha512_224.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsHashMethod_SHA512_224()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA512_224
+//
+// Purpose: Return SHA512_224 method.
+//
+// Returns:
+// Pointer to SHA512_224 hash-method.
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA512_224, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA512_224,
+ IPP_SHA224_DIGEST_BITSIZE/8,
+ MBS_SHA512,
+ MLR_SHA512,
+ sha512_224_hashInit,
+ sha512_hashUpdate,
+ sha512_224_hashOctString,
+ sha512_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sha512_256.c b/ext/ipp/sources/ippcp/pcphashmethod_sha512_256.c
new file mode 100644
index 0000000..b8865c3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sha512_256.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsHashMethod_SHA512_256()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SHA512_256
+//
+// Purpose: Return SHA512_256 method.
+//
+// Returns:
+// Pointer to SHA512_256 hash-method.
+//
+*F*/
+
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA512_256, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SHA512_256,
+ IPP_SHA256_DIGEST_BITSIZE/8,
+ MBS_SHA512,
+ MLR_SHA512,
+ sha512_256_hashInit,
+ sha512_hashUpdate,
+ sha512_256_hashOctString,
+ sha512_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashmethod_sm3.c b/ext/ipp/sources/ippcp/pcphashmethod_sm3.c
new file mode 100644
index 0000000..32decbd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashmethod_sm3.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SM3
+//
+// Contents:
+// ippsHashMethod_SM3()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsm3stuff.h"
+
+/*F*
+// Name: ippsHashMethod_SM3
+//
+// Purpose: Return SM3 method.
+//
+// Returns:
+// Pointer to SM3 hash-method.
+//
+*F*/
+IPPFUN( const IppsHashMethod*, ippsHashMethod_SM3, (void) )
+{
+ static IppsHashMethod method = {
+ ippHashAlg_SM3,
+ IPP_SM3_DIGEST_BITSIZE/8,
+ MBS_SM3,
+ MLR_SM3,
+ sm3_hashInit,
+ sm3_hashUpdate,
+ sm3_hashOctString,
+ sm3_msgRep
+ };
+ return &method;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashpack.c b/ext/ipp/sources/ippcp/pcphashpack.c
new file mode 100644
index 0000000..37d7fb0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashpack.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashPack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashPack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// pBuffer == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsNoMemErr bufSize < sizeof(IppsHashState)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer hash state
+// pBuffer pointer to the destination buffer
+// bufSize size of the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsHashPack,(const IppsHashState* pState, Ipp8u* pBuffer, int bufSize))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ /* test the context */
+ IPP_BADARG_RET(!HASH_VALID_ID(pState), ippStsContextMatchErr);
+ /* test buffer length */
+ IPP_BADARG_RET((int)(sizeof(IppsHashState))>bufSize, ippStsNoMemErr);
+
+ CopyBlock(pState, pBuffer, sizeof(IppsHashState));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashpack_rmf.c b/ext/ipp/sources/ippcp/pcphashpack_rmf.c
new file mode 100644
index 0000000..dd1466f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashpack_rmf.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashPack_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashPack_rmf
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsNoMemErr bufSize < sizeof(IppsHashState_rmf)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer hash state
+// pBuffer pointer to the destination buffer
+// bufSize size of the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsHashPack_rmf,(const IppsHashState_rmf* pState, Ipp8u* pBuffer, int bufSize))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pState, HASH_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+ /* test buffer length */
+ IPP_BADARG_RET((int)(sizeof(IppsHashState_rmf)+HASH_ALIGNMENT-1)>bufSize, ippStsNoMemErr);
+
+ CopyBlock(pState, pBuffer, sizeof(IppsHashState_rmf));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcphashsha1px.c b/ext/ipp/sources/ippcp/pcphashsha1px.c
index 842443c..62838fd 100644
--- a/ext/ipp/sources/ippcp/src/pcphashsha1px.c
+++ b/ext/ipp/sources/ippcp/pcphashsha1px.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -43,8 +67,7 @@
(_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
(_IPP32E==_IPP32E_M7) || \
(_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9) || \
- (_IPP64==_IPP64_I7) )
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
/*
// Magic functions defined in FIPS 180-1
diff --git a/ext/ipp/sources/ippcp/src/pcphashsha256px.c b/ext/ipp/sources/ippcp/pcphashsha256px.c
index d0a7330..5b7044a 100644
--- a/ext/ipp/sources/ippcp/src/pcphashsha256px.c
+++ b/ext/ipp/sources/ippcp/pcphashsha256px.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -35,7 +59,7 @@
#pragma message("IPP_ALG_HASH_SHA256 disabled")
#else
-//#pragma message("IPP_ALG_HASH_SHA256 enabled")
+#pragma message("IPP_ALG_HASH_SHA256 enabled")
#if !((_IPP==_IPP_M5) || \
(_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \
@@ -43,8 +67,7 @@
(_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
(_IPP32E==_IPP32E_M7) || \
(_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9) || \
- (_IPP64==_IPP64_I7) )
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
/*
// SHA256 Specific Macros (reference proposal 256-384-512)
diff --git a/ext/ipp/sources/ippcp/src/pcphashsha512px.c b/ext/ipp/sources/ippcp/pcphashsha512px.c
index cd50b97..5b098da 100644
--- a/ext/ipp/sources/ippcp/src/pcphashsha512px.c
+++ b/ext/ipp/sources/ippcp/pcphashsha512px.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -35,15 +59,14 @@
#pragma message("IPP_ALG_HASH_SHA512 disabled")
#else
-//#pragma message("IPP_ALG_HASH_SHA512 enabled")
+#pragma message("IPP_ALG_HASH_SHA512 enabled")
#if !((_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \
(_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \
(_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
(_IPP32E==_IPP32E_M7) || \
(_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9) || \
- (_IPP64==_IPP64_I7) )
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
/*
// SHA512 Specific Macros (reference proposal 256-384-512)
diff --git a/ext/ipp/sources/ippcp/pcphashsm3px.c b/ext/ipp/sources/ippcp/pcphashsm3px.c
new file mode 100644
index 0000000..9089edb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashsm3px.c
@@ -0,0 +1,366 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Message block processing according to SM5
+//
+// Contents:
+// UpdateSM3()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+#if !defined(_ENABLE_ALG_SM3_)
+#pragma message("IPP_ALG_HASH_SM3 disabled")
+
+#else
+#pragma message("IPP_ALG_HASH_SM3 enabled")
+
+#if !((_IPP32E>=_IPP32E_U8) || (_IPP32E==_IPP32E_N8) )
+
+/*
+// SM3 Specific Macros
+// (reference SM3 Cryptographic Hash Algorithm,
+// Chinese Commercial Cryptography Administration Office, 2010.12)
+*/
+
+/* T1 and T2 are base for additive const generation */
+#define T1 (0x79CC4519)
+#define T2 (0x7A879D8A)
+
+// boolean functions (0<=nr<16)
+#define FF1(x,y,z) ((x)^(y)^(z))
+#define GG1(x,y,z) ((x)^(y)^(z))
+// boolean functions (16<=nr<64)
+#define FF2(x,y,z) (((x)&(y)) | ((x)&(z)) | ((y)&(z)))
+#define GG2(x,y,z) (((x)&(y)) | (~(x)&(z)))
+
+// P0 permutation:
+#define P0(x) ((x) ^ ROL32((x),9) ^ ROL32((x),17))
+// P1 permutation:
+#define P1(x) ((x) ^ ROL32((x),15) ^ ROL32((x),23))
+
+// update W
+#define WUPDATE(nr, W) (P1(W[((nr)-16)&15] ^ W[((nr)-9)&15] ^ ROL32(W[((nr)-3)&15],15)) ^ ROL32(W[((nr)-13)&15],7) ^ W[((nr)-6)&15])
+
+// SM3 steps
+#define SM3_STEP1(nr, A,B,C,D,E,F,G,H, Tj, W) { \
+ TT1 = FF1(A,B,C) + D + (W[nr&15] ^ W[(nr+4)&15]); \
+ TT2 = GG1(E,F,G) + H + W[nr&15]; \
+ H = ROL32(A,12); \
+ D = ROL32(H + E +Tj, 7); \
+ H ^= D; \
+ D += TT2; \
+ H += TT1; \
+ B = ROL32(B, 9); \
+ D = P0(D); \
+ F = ROL32(F, 19); \
+ /*Tj = ROL32(Tj, 1);*/ \
+ W[(nr)&15] = WUPDATE(nr, W); \
+}
+
+#define SM3_STEP2(nr, A,B,C,D,E,F,G,H, Tj, W) { \
+ TT1 = FF2(A,B,C) + D + (W[nr&15] ^ W[(nr+4)&15]); \
+ TT2 = GG2(E,F,G) + H + W[nr&15]; \
+ H = ROL32(A,12); \
+ D = ROL32(H + E +Tj, 7); \
+ H ^= D; \
+ D += TT2; \
+ H += TT1; \
+ B = ROL32(B, 9); \
+ D = P0(D); \
+ F = ROL32(F, 19); \
+ /*Tj = ROL32(Tj, 1);*/ \
+ W[(nr)&15] = WUPDATE(nr, W); \
+}
+
+#define SM3_STEP3(nr, A,B,C,D,E,F,G,H, Tj, W) { \
+ TT1 = FF2(A,B,C) + D + (W[nr&15] ^ W[(nr+4)&15]); \
+ TT2 = GG2(E,F,G) + H + W[nr&15]; \
+ H = ROL32(A,12); \
+ D = ROL32(H + E +Tj, 7); \
+ H ^= D; \
+ D += TT2; \
+ H += TT1; \
+ B = ROL32(B, 9); \
+ D = P0(D); \
+ F = ROL32(F, 19); \
+ /*Tj = ROL32(Tj, 1);*/ \
+}
+
+#define COMPACT_SM3_STEP(A,B,C,D,E,F,G,H, FF, GG, W,Tj, r) { \
+ TT1 = FF((r)&0x30, A,B,C) + D + (W[(r)] ^ W[(r)+4]); \
+ TT2 = GG((r)&0x30, E,F,G) + H + W[(r)]; \
+ \
+ _H = ROL32(A,12); \
+ _D = ROL32(_H + E +Tj[(r)], 7); \
+ _H ^= _D; \
+ _D += TT2; \
+ _H += TT1; \
+ _D = P0(_D);\
+ \
+ H = G; \
+ G = ROL32(F,19); \
+ F = E; \
+ E =_D; \
+ D = C; \
+ C = ROL32(B, 9); \
+ B = A; \
+ A =_H; \
+}
+
+
+/*F*
+// Name: UpdateSM3
+//
+// Purpose: Update internal hash according to input message stream.
+//
+// Parameters:
+// uniHash pointer to in/out hash
+// mblk pointer to message stream
+// mlen message stream length (multiple by message block size)
+// uniParam pointer to the optional parameter
+//
+*F*/
+#if defined(_ALG_SM3_COMPACT_)
+#pragma message("SM3 compact")
+
+__INLINE Ipp32u MagicFF(int s, Ipp32u a, Ipp32u b, Ipp32u c)
+{
+ switch(s) {
+ case 0: return FF1(a,b,c);
+ default:return FF2(a,b,c);
+ }
+}
+__INLINE Ipp32u MagicGG(int s, Ipp32u e, Ipp32u f, Ipp32u g)
+{
+ switch(s) {
+ case 0: return GG1(e,f,g);
+ default:return GG2(e,f,g);
+ }
+}
+
+void UpdateSM3(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam)
+{
+ Ipp32u* data = (Ipp32u*)mblk;
+
+ Ipp32u* hash = (Ipp32u*)uniHash;
+ Ipp32u* SM3_cnt_loc = (Ipp32u*)uniParam;
+
+ for(; mlen>=MBS_SM3; data += MBS_SM3/sizeof(Ipp32u), mlen -= MBS_SM3) {
+ int r;
+
+ /*
+ // expand message block
+ */
+ Ipp32u W[68];
+ /* initialize the first 16 words in the array W (remember about endian) */
+ for(r=0; r<16; r++) {
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ W[r] = data[r];
+ #else
+ W[r] = ENDIANNESS( data[r] );
+ #endif
+ }
+ for(; r<68; r++)
+ W[r] = P1(W[r-16] ^ W[r-9] ^ ROL32(W[r-3],15)) ^ ROL32(W[r-13],7) ^ W[r-6];
+
+ /*
+ // update hash
+ */
+ {
+ /* init A, B, C, D, E, F, G, H by the input hash */
+ Ipp32u A = hash[0];
+ Ipp32u B = hash[1];
+ Ipp32u C = hash[2];
+ Ipp32u D = hash[3];
+ Ipp32u E = hash[4];
+ Ipp32u F = hash[5];
+ Ipp32u G = hash[6];
+ Ipp32u H = hash[7];
+
+ Ipp32u TT1, TT2, _H, _D;
+ for(r=0; r<64; r++)
+ COMPACT_SM3_STEP(A,B,C,D,E,F,G,H, MagicFF,MagicGG, W, SM3_cnt_loc, r);
+
+ /* update hash */
+ hash[0] ^= A;
+ hash[1] ^= B;
+ hash[2] ^= C;
+ hash[3] ^= D;
+ hash[4] ^= E;
+ hash[5] ^= F;
+ hash[6] ^= G;
+ hash[7] ^= H;
+ }
+ }
+}
+
+#else
+void UpdateSM3(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam)
+{
+ Ipp32u* data = (Ipp32u*)mblk;
+
+ Ipp32u* hash = (Ipp32u*)uniHash;
+ Ipp32u* SM3_cnt_loc = (Ipp32u*)uniParam;
+
+ for(; mlen>=MBS_SM3; data += MBS_SM3/sizeof(Ipp32u), mlen -= MBS_SM3) {
+
+ /* copy input hash */
+ Ipp32u A = hash[0];
+ Ipp32u B = hash[1];
+ Ipp32u C = hash[2];
+ Ipp32u D = hash[3];
+ Ipp32u E = hash[4];
+ Ipp32u F = hash[5];
+ Ipp32u G = hash[6];
+ Ipp32u H = hash[7];
+
+ Ipp32u W[16];
+ int j;
+
+
+ /* initialize the first 16 words in the array W (remember about endian) */
+ for(j=0; j<16; j++) {
+ #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
+ W[j] = data[j];
+ #else
+ W[j] = ENDIANNESS( data[j] );
+ #endif
+ }
+
+ /* apply compression function */
+ {
+ Ipp32u TT1, TT2;
+ SM3_STEP1( 0, A,B,C,D,E,F,G,H, SM3_cnt_loc[0], W);
+ SM3_STEP1( 1, H,A,B,C,D,E,F,G, SM3_cnt_loc[1], W);
+ SM3_STEP1( 2, G,H,A,B,C,D,E,F, SM3_cnt_loc[2], W);
+ SM3_STEP1( 3, F,G,H,A,B,C,D,E, SM3_cnt_loc[3], W);
+ SM3_STEP1( 4, E,F,G,H,A,B,C,D, SM3_cnt_loc[4], W);
+ SM3_STEP1( 5, D,E,F,G,H,A,B,C, SM3_cnt_loc[5], W);
+ SM3_STEP1( 6, C,D,E,F,G,H,A,B, SM3_cnt_loc[6], W);
+ SM3_STEP1( 7, B,C,D,E,F,G,H,A, SM3_cnt_loc[7], W);
+
+ SM3_STEP1( 8, A,B,C,D,E,F,G,H, SM3_cnt_loc[ 8], W);
+ SM3_STEP1( 9, H,A,B,C,D,E,F,G, SM3_cnt_loc[ 9], W);
+ SM3_STEP1(10, G,H,A,B,C,D,E,F, SM3_cnt_loc[10], W);
+ SM3_STEP1(11, F,G,H,A,B,C,D,E, SM3_cnt_loc[11], W);
+ SM3_STEP1(12, E,F,G,H,A,B,C,D, SM3_cnt_loc[12], W);
+ SM3_STEP1(13, D,E,F,G,H,A,B,C, SM3_cnt_loc[13], W);
+ SM3_STEP1(14, C,D,E,F,G,H,A,B, SM3_cnt_loc[14], W);
+ SM3_STEP1(15, B,C,D,E,F,G,H,A, SM3_cnt_loc[15], W);
+
+ SM3_STEP2(16, A,B,C,D,E,F,G,H, SM3_cnt_loc[16], W);
+ SM3_STEP2(17, H,A,B,C,D,E,F,G, SM3_cnt_loc[17], W);
+ SM3_STEP2(18, G,H,A,B,C,D,E,F, SM3_cnt_loc[18], W);
+ SM3_STEP2(19, F,G,H,A,B,C,D,E, SM3_cnt_loc[19], W);
+ SM3_STEP2(20, E,F,G,H,A,B,C,D, SM3_cnt_loc[20], W);
+ SM3_STEP2(21, D,E,F,G,H,A,B,C, SM3_cnt_loc[21], W);
+ SM3_STEP2(22, C,D,E,F,G,H,A,B, SM3_cnt_loc[22], W);
+ SM3_STEP2(23, B,C,D,E,F,G,H,A, SM3_cnt_loc[23], W);
+
+ SM3_STEP2(24, A,B,C,D,E,F,G,H, SM3_cnt_loc[24], W);
+ SM3_STEP2(25, H,A,B,C,D,E,F,G, SM3_cnt_loc[25], W);
+ SM3_STEP2(26, G,H,A,B,C,D,E,F, SM3_cnt_loc[26], W);
+ SM3_STEP2(27, F,G,H,A,B,C,D,E, SM3_cnt_loc[27], W);
+ SM3_STEP2(28, E,F,G,H,A,B,C,D, SM3_cnt_loc[28], W);
+ SM3_STEP2(29, D,E,F,G,H,A,B,C, SM3_cnt_loc[29], W);
+ SM3_STEP2(30, C,D,E,F,G,H,A,B, SM3_cnt_loc[30], W);
+ SM3_STEP2(31, B,C,D,E,F,G,H,A, SM3_cnt_loc[31], W);
+
+ SM3_STEP2(32, A,B,C,D,E,F,G,H, SM3_cnt_loc[32], W);
+ SM3_STEP2(33, H,A,B,C,D,E,F,G, SM3_cnt_loc[33], W);
+ SM3_STEP2(34, G,H,A,B,C,D,E,F, SM3_cnt_loc[34], W);
+ SM3_STEP2(35, F,G,H,A,B,C,D,E, SM3_cnt_loc[35], W);
+ SM3_STEP2(36, E,F,G,H,A,B,C,D, SM3_cnt_loc[36], W);
+ SM3_STEP2(37, D,E,F,G,H,A,B,C, SM3_cnt_loc[37], W);
+ SM3_STEP2(38, C,D,E,F,G,H,A,B, SM3_cnt_loc[38], W);
+ SM3_STEP2(39, B,C,D,E,F,G,H,A, SM3_cnt_loc[39], W);
+
+ SM3_STEP2(40, A,B,C,D,E,F,G,H, SM3_cnt_loc[40], W);
+ SM3_STEP2(41, H,A,B,C,D,E,F,G, SM3_cnt_loc[41], W);
+ SM3_STEP2(42, G,H,A,B,C,D,E,F, SM3_cnt_loc[42], W);
+ SM3_STEP2(43, F,G,H,A,B,C,D,E, SM3_cnt_loc[43], W);
+ SM3_STEP2(44, E,F,G,H,A,B,C,D, SM3_cnt_loc[44], W);
+ SM3_STEP2(45, D,E,F,G,H,A,B,C, SM3_cnt_loc[45], W);
+ SM3_STEP2(46, C,D,E,F,G,H,A,B, SM3_cnt_loc[46], W);
+ SM3_STEP2(47, B,C,D,E,F,G,H,A, SM3_cnt_loc[47], W);
+
+ SM3_STEP2(48, A,B,C,D,E,F,G,H, SM3_cnt_loc[48], W);
+ SM3_STEP2(49, H,A,B,C,D,E,F,G, SM3_cnt_loc[49], W);
+ SM3_STEP2(50, G,H,A,B,C,D,E,F, SM3_cnt_loc[50], W);
+ SM3_STEP2(51, F,G,H,A,B,C,D,E, SM3_cnt_loc[51], W);
+ SM3_STEP3(52, E,F,G,H,A,B,C,D, SM3_cnt_loc[52], W);
+ SM3_STEP3(53, D,E,F,G,H,A,B,C, SM3_cnt_loc[53], W);
+ SM3_STEP3(54, C,D,E,F,G,H,A,B, SM3_cnt_loc[54], W);
+ SM3_STEP3(55, B,C,D,E,F,G,H,A, SM3_cnt_loc[55], W);
+
+ SM3_STEP3(56, A,B,C,D,E,F,G,H, SM3_cnt_loc[56], W);
+ SM3_STEP3(57, H,A,B,C,D,E,F,G, SM3_cnt_loc[57], W);
+ SM3_STEP3(58, G,H,A,B,C,D,E,F, SM3_cnt_loc[58], W);
+ SM3_STEP3(59, F,G,H,A,B,C,D,E, SM3_cnt_loc[59], W);
+ SM3_STEP3(60, E,F,G,H,A,B,C,D, SM3_cnt_loc[60], W);
+ SM3_STEP3(61, D,E,F,G,H,A,B,C, SM3_cnt_loc[61], W);
+ SM3_STEP3(62, C,D,E,F,G,H,A,B, SM3_cnt_loc[62], W);
+ SM3_STEP3(63, B,C,D,E,F,G,H,A, SM3_cnt_loc[63], W);
+ }
+ /* update hash */
+ hash[0] ^= A;
+ hash[1] ^= B;
+ hash[2] ^= C;
+ hash[3] ^= D;
+ hash[4] ^= E;
+ hash[5] ^= F;
+ hash[6] ^= G;
+ hash[7] ^= H;
+ }
+}
+#endif
+
+#endif /* _PX/_W7/_T7, _MX/_M7 versions */
+#endif /* IPP_ALG_HASH_SM3 */
diff --git a/ext/ipp/sources/ippcp/pcphashunpack.c b/ext/ipp/sources/ippcp/pcphashunpack.c
new file mode 100644
index 0000000..fadb966
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashunpack.c
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashUnpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashUnpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the source buffer
+// pState pointer hash state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashUnpack,(const Ipp8u* pBuffer, IppsHashState* pState))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+
+ CopyBlock(pBuffer, pState, sizeof(IppsHashState));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashunpack_rmf.c b/ext/ipp/sources/ippcp/pcphashunpack_rmf.c
new file mode 100644
index 0000000..9d3afa5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashunpack_rmf.c
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashUnpack_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashUnpack_rmf
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBuffer == NULL
+// pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the source buffer
+// pState pointer hash state
+//
+*F*/
+IPPFUN(IppStatus, ippsHashUnpack_rmf,(const Ipp8u* pBuffer, IppsHashState_rmf* pState))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+
+ CopyBlock(pBuffer, pState, sizeof(IppsHashState_rmf));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashupdate.c b/ext/ipp/sources/ippcp/pcphashupdate.c
new file mode 100644
index 0000000..8323a40
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashupdate.c
@@ -0,0 +1,160 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// General Functionality
+//
+// Contents:
+// ippsHashUpdate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsHashUpdate
+//
+// Purpose: Updates intermediate hash value based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pSrc==0 but len!=0
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the Hash context
+//
+*F*/
+__INLINE int IsExceedMsgLen(Ipp64u maxLo, Ipp64u maxHi, Ipp64u lenLo, Ipp64u lenHi)
+{
+ int isExceed = lenLo > maxLo;
+ isExceed = (lenHi+isExceed) > maxHi;
+ return isExceed;
+}
+
+IPPFUN(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ /* test the context */
+ IPP_BADARG_RET(!HASH_VALID_ID(pState), ippStsContextMatchErr);
+ /* test input length */
+ IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr);
+ /* test source pointer */
+ IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
+
+ /* handle non empty input */
+ if(len) {
+ const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pState)];
+
+ /* test if size of message is being processed not exceeded yet */
+ Ipp64u lenLo = HASH_LENLO(pState);
+ Ipp64u lenHi = HASH_LENHI(pState);
+ lenLo += len;
+ if(lenLo < HASH_LENLO(pState)) lenHi++;
+ if(IsExceedMsgLen(pAttr->msgLenMax[0],pAttr->msgLenMax[1], lenLo,lenHi))
+ IPP_ERROR_RET(ippStsLengthErr);
+
+ else {
+ cpHashProc hashFunc = HASH_FUNC(pState); /* processing function */
+ const void* pParam = HASH_FUNC_PAR(pState); /* and it's addition params */
+ int mbs = pAttr->msgBlkSize; /* data block size */
+
+ /*
+ // processing
+ */
+ {
+ int procLen;
+
+ /* test if internal buffer is not empty */
+ int n = HAHS_BUFFIDX(pState);
+ if(n) {
+ procLen = IPP_MIN(len, (mbs-n));
+ CopyBlock(pSrc, HASH_BUFF(pState)+n, procLen);
+ HAHS_BUFFIDX(pState) = n += procLen;
+
+ /* block processing */
+ if(mbs==n) {
+ hashFunc(HASH_VALUE(pState), HASH_BUFF(pState), mbs, pParam);
+ HAHS_BUFFIDX(pState) = 0;
+ }
+
+ /* update message pointer and length */
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* main processing part */
+ procLen = len & ~(mbs-1);
+ if(procLen) {
+ hashFunc(HASH_VALUE(pState), pSrc, procLen, pParam);
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* rest of input message */
+ if(len) {
+ CopyBlock(pSrc, HASH_BUFF(pState), len);
+ HAHS_BUFFIDX(pState) += len;
+ }
+ }
+
+ /* update length of processed message */
+ HASH_LENLO(pState) = lenLo;
+ HASH_LENHI(pState) = lenHi;
+
+ return ippStsNoErr;
+ }
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphashupdate_rmf.c b/ext/ipp/sources/ippcp/pcphashupdate_rmf.c
new file mode 100644
index 0000000..ef79621
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphashupdate_rmf.c
@@ -0,0 +1,139 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Security Hash Standard
+// Generalized Functionality
+//
+// Contents:
+// ippsHashUpdate_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsHashUpdate_rmf
+//
+// Purpose: Updates intermediate hash value based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNullPtrErr pSrc==0 but len!=0
+// ippStsContextMatchErr pState->idCtx != idCtxHash
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the Hash context
+//
+*F*/
+IPPFUN(IppStatus, ippsHashUpdate_rmf,(const Ipp8u* pSrc, int len, IppsHashState_rmf* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pState, HASH_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test input length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test source pointer */
+ IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
+
+ if(len) {
+ const IppsHashMethod* method = HASH_METHOD(pState);
+ hashUpdateF hashFunc = method->hashUpdate; /* processing function */
+ int msgBlkSize = method->msgBlkSize; /* messge block size */
+
+ int procLen;
+
+ int idx = HAHS_BUFFIDX(pState);
+ Ipp64u lenLo = HASH_LENLO(pState);
+ Ipp64u lenHi = HASH_LENHI(pState);
+ lenLo += len;
+ if(lenLo < HASH_LENLO(pState)) lenHi++;
+
+ /* if internal buffer is not empty */
+ if(idx) {
+ procLen = IPP_MIN(len, (msgBlkSize-idx));
+ CopyBlock(pSrc, HASH_BUFF(pState)+idx, procLen);
+ idx += procLen;
+
+ /* process complete message block */
+ if(msgBlkSize==idx) {
+ hashFunc(HASH_VALUE(pState), HASH_BUFF(pState), msgBlkSize);
+ idx = 0;
+ }
+
+ /* update message pointer and length */
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* process main part of the input*/
+ procLen = len & ~(msgBlkSize-1);
+ if(procLen) {
+ hashFunc(HASH_VALUE(pState), pSrc, procLen);
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* store the rest of input in the buffer */
+ if(len) {
+ CopyBlock(pSrc, HASH_BUFF(pState), len);
+ idx += len;
+ }
+
+ /* update length of processed message */
+ HASH_LENLO(pState) = lenLo;
+ HASH_LENHI(pState) = lenHi;
+ HAHS_BUFFIDX(pState) = idx;
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcphmac.h b/ext/ipp/sources/ippcp/pcphmac.h
new file mode 100644
index 0000000..d39462b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphmac.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Hash Message Authentication Code
+// Internal Definitions and Internal Functions Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_HMAC_H)
+#define _PCP_HMAC_H
+
+#include "pcphash.h"
+
+/*
+// HMAC context
+*/
+struct _cpHMAC {
+ IppCtxId idCtx; /* HMAC identifier */
+ Ipp8u ipadKey[MBS_HASH_MAX]; /* inner padding key */
+ Ipp8u opadKey[MBS_HASH_MAX]; /* outer padding key */
+ IppsHashState hashCtx; /* hash context */
+};
+
+/* accessors */
+#define HMAC_CTX_ID(stt) ((stt)->idCtx)
+#define HASH_CTX(stt) ((stt)->hashCtx)
+#define HMAC_VALID_ID(stt) (HMAC_CTX_ID((stt))==idCtxHMAC)
+
+#define IPAD (0x36) /* inner padding value */
+#define OPAD (0x5C) /* outer padding value */
+
+#endif /* _PCP_HMAC_H */
diff --git a/ext/ipp/sources/ippcp/pcphmac_rmf.h b/ext/ipp/sources/ippcp/pcphmac_rmf.h
new file mode 100644
index 0000000..715b9e3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcphmac_rmf.h
@@ -0,0 +1,64 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// Hash Message Authentication Code
+// Internal Definitions and Internal Functions Prototypes
+*/
+
+#if !defined(_PCP_HMAC_RMF_H)
+#define _PCP_HMAC_RMF_H
+
+#include "pcphash_rmf.h"
+
+/*
+// HMAC context
+*/
+struct _cpHMAC_rmf {
+ IppCtxId idCtx; /* HMAC identifier */
+ Ipp8u ipadKey[MBS_HASH_MAX]; /* inner padding key */
+ Ipp8u opadKey[MBS_HASH_MAX]; /* outer padding key */
+ IppsHashState_rmf hashCtx; /* hash context */
+};
+
+
+#endif /* _PCP_HMAC_RMF_H */
diff --git a/ext/ipp/sources/ippcp/pcpmask_ct.h b/ext/ipp/sources/ippcp/pcpmask_ct.h
new file mode 100644
index 0000000..7441fbd
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmask_ct.h
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Constant time Mask operations
+//
+//
+*/
+
+#if !defined(_PCP_MASK_CT_H)
+#define _PCP_MASK_CT_H
+
+#include "owncp.h"
+#include "pcpbnuimpl.h"
+
+/*
+// The following functions test particular conditions
+// and returns either 0 or 0xffffffff.
+//
+// The result is suitable for boolean and masked operations.
+//
+// Inspite of operation below are using BNU_CHUNK_T operand(s) it can be applied to Ipp32u, Ipp32s, Ipp16u, Ipp16s, Ipp8u and Ipp8s too.
+// For example, if
+// Ipp32u uns_int;
+// Ipp32s sgn_int;
+// Ipp8u uns_char;
+// Ipp8s sgn_char;
+// then
+// cpIs_msb_ct((Ipp32s)uns_int) tests 31 bit of uns_int
+// cpIs_msb_ct( sgn_int) tests 31 bit of sgn_int
+// cpIs_msb_ct((Ipp8u)uns_char) tests 7 bit of uns_char
+// cpIs_msb_ct( sgn_char) tests 7 bit of sgn_char
+*/
+
+/* tests if MSB(a)==1 */
+__INLINE BNU_CHUNK_T cpIsMsb_ct(BNU_CHUNK_T a)
+{
+ return (BNU_CHUNK_T)0 - (a >> (sizeof(a) * 8 - 1));
+}
+
+/* tests if LSB(a)==1 */
+__INLINE BNU_CHUNK_T cpIsLsb_ct(BNU_CHUNK_T a)
+{
+ return (BNU_CHUNK_T)0 - (a & 1);
+}
+
+/* tests if a is odd */
+__INLINE BNU_CHUNK_T cpIsOdd_ct(BNU_CHUNK_T a)
+{
+ return cpIsLsb_ct(a);
+}
+
+/* tests if a is even */
+__INLINE BNU_CHUNK_T cpIsEven_ct(BNU_CHUNK_T a)
+{
+ return ~cpIsLsb_ct(a);
+}
+
+/* tests if a==0 */
+__INLINE BNU_CHUNK_T cpIsZero_ct(BNU_CHUNK_T a)
+{
+ return cpIsMsb_ct(~a & (a - 1));
+}
+
+/* tests if a==b */
+__INLINE BNU_CHUNK_T cpIsEqu_ct(BNU_CHUNK_T a, BNU_CHUNK_T b)
+{
+ return cpIsZero_ct(a ^ b);
+}
+
+/* replace under mask: dst[] = replaceFlag? src[] : dst[] */
+__INLINE void cpMaskedReplace_ct(BNU_CHUNK_T* dst, const BNU_CHUNK_T* src, int len, BNU_CHUNK_T replaceMask)
+{
+ BNU_CHUNK_T dstMask = ~replaceMask;
+ int n;
+ for(n=0; n<len; n++)
+ dst[n] = (src[n] & replaceMask) ^ (dst[n] & dstMask);
+}
+
+/* copy under mask: dst[] = src1[] & mask) ^ src2[] & ~mask */
+__INLINE void cpMaskedCopyBNU_ct(BNU_CHUNK_T* dst, BNU_CHUNK_T mask, const BNU_CHUNK_T* src1, const BNU_CHUNK_T* src2, int len)
+{
+ int i;
+ for(i=0; i<(len); i++)
+ dst[i] = (src1[i] & mask) ^ (src2[i] & ~mask);
+}
+
+/* test if GF elmement is equal to x chunk */
+__INLINE BNU_CHUNK_T cpIsGFpElemEquChunk_ct(const BNU_CHUNK_T* pE, int nsE, BNU_CHUNK_T x)
+{
+ int i;
+ BNU_CHUNK_T accum = pE[0] ^ x;
+ for (i = 1; i < nsE; i++) {
+ accum |= pE[i];
+ }
+ return cpIsZero_ct(accum);
+}
+
+#define GFPE_IS_ZERO_CT(a,size) cpIsGFpElemEquChunk_ct((a),(size), 0)
+
+#endif /* _PCP_MASK_CT_H */
diff --git a/ext/ipp/sources/ippcp/pcpmd5stuff.h b/ext/ipp/sources/ippcp/pcpmd5stuff.h
new file mode 100644
index 0000000..649c499
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmd5stuff.h
@@ -0,0 +1,124 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to MD5
+// (derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm)
+//
+// Equivalent code is available from RFC 1321.
+//
+// Contents:
+// MD4 methods and constants
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+#if !defined(_PCP_MD5_STUFF_H)
+#define _PCP_MD5_STUFF_H
+
+/* MD5 constants */
+static const Ipp32u md5_iv[] = {
+ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476};
+
+static __ALIGN16 const Ipp32u md5_cnt[] = {
+ 0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE,
+ 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
+ 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE,
+ 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821,
+
+ 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA,
+ 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8,
+ 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED,
+ 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A,
+
+ 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C,
+ 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70,
+ 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05,
+ 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665,
+
+ 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039,
+ 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1,
+ 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1,
+ 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391
+};
+
+static void md5_hashInit(void* pHash)
+{
+ /* setup initial digest */
+ ((Ipp32u*)pHash)[0] = md5_iv[0];
+ ((Ipp32u*)pHash)[1] = md5_iv[1];
+ ((Ipp32u*)pHash)[2] = md5_iv[2];
+ ((Ipp32u*)pHash)[3] = md5_iv[3];
+}
+
+static void md5_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateMD5(pHash, pMsg, msgLen, md5_cnt);
+}
+
+static void md5_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ /* md5 does not need conversion into big endian */
+ ((Ipp32u*)pMD)[0] = ((Ipp32u*)pHashVal)[0];
+ ((Ipp32u*)pMD)[1] = ((Ipp32u*)pHashVal)[1];
+ ((Ipp32u*)pMD)[2] = ((Ipp32u*)pHashVal)[2];
+ ((Ipp32u*)pMD)[3] = ((Ipp32u*)pHashVal)[3];
+}
+
+static void md5_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
+{
+ UNREFERENCED_PARAMETER(lenHi);
+ lenLo <<= 3;
+ ((Ipp64u*)(pDst))[0] = lenLo;
+}
+
+#define cpFinalizeMD5 OWNAPI(cpFinalizeMD5)
+
+void cpFinalizeMD5(DigestMD5 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen);
+
+#endif /* #if !defined(_PCP_MD5_STUFF_H) */
diff --git a/ext/ipp/sources/ippcp/pcpmgf1ca_rmf.c b/ext/ipp/sources/ippcp/pcpmgf1ca_rmf.c
new file mode 100644
index 0000000..30a1d1f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmgf1ca_rmf.c
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// HASH based Mask Generation Functions
+//
+// Contents:
+// ippsMGF1_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMGF1
+//
+// Purpose: Mask Generation Functios.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMask == NULL
+// pMethod ==NULL
+// ippStsLengthErr seedLen <0
+// maskLen <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSeed pointer to the input stream
+// seedLen input stream length (bytes)
+// pMaske pointer to the ouput mask
+// maskLen desired length of mask (bytes)
+// pMethod hash method
+//
+//
+// Note.
+// MGF1 defined in the IEEE P1363 standard.
+// MGF1 defined in the ANSI X9.63 standard and frequently called KDF (key Generation Function).
+// The fifference between MGF1 and MGF2 is negligible - counter i runs from 0 (in MGF1) and from 1 (in MGF2)
+*F*/
+IPPFUN(IppStatus, ippsMGF1_rmf,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, const IppsHashMethod* pMethod))
+{
+ IPP_BAD_PTR2_RET(pMask, pMethod);
+ IPP_BADARG_RET((seedLen<0)||(maskLen<0), ippStsLengthErr);
+
+ {
+ /* hash specific */
+ int hashSize = pMethod->hashLen;
+
+ int i, outLen;
+
+ __ALIGN8 IppsHashState_rmf hashCtx;
+ ippsHashInit_rmf(&hashCtx, pMethod);
+
+ if(!pSeed)
+ seedLen = 0;
+
+ for(i=0,outLen=0; outLen<maskLen; i++) { /* counter i runs from 0 */
+ Ipp8u cnt[4];
+ cnt[0] = (Ipp8u)((i>>24) & 0xFF);
+ cnt[1] = (Ipp8u)((i>>16) & 0xFF);
+ cnt[2] = (Ipp8u)((i>>8) & 0xFF);
+ cnt[3] = (Ipp8u)(i & 0xFF);
+
+ ippsHashUpdate_rmf(pSeed, seedLen, &hashCtx);
+ ippsHashUpdate_rmf(cnt, 4, &hashCtx);
+
+ if((outLen + hashSize) <= maskLen) {
+ ippsHashFinal_rmf(pMask+outLen, &hashCtx);
+ outLen += hashSize;
+ }
+ else {
+ Ipp8u md[MAX_HASH_SIZE];
+ ippsHashFinal_rmf(md, &hashCtx);
+ CopyBlock(md, pMask+outLen, maskLen-outLen);
+ outLen = maskLen;
+ }
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmgf2ca_rmf.c b/ext/ipp/sources/ippcp/pcpmgf2ca_rmf.c
new file mode 100644
index 0000000..3f0bb5a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmgf2ca_rmf.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// HASH based Mask Generation Functions
+//
+// Contents:
+// ippsMGF2_rmf()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMGF2
+//
+// Purpose: Mask Generation Functios.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMask == NULL
+// pMethod ==NULL
+// ippStsLengthErr seedLen <0
+// maskLen <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSeed pointer to the input stream
+// seedLen input stream length (bytes)
+// pMaske pointer to the ouput mask
+// maskLen desired length of mask (bytes)
+// pMethod hash method
+//
+//
+// Note.
+// MGF1 defined in the IEEE P1363 standard.
+// MGF1 defined in the ANSI X9.63 standard and frequently called KDF (key Generation Function).
+// The fifference between MGF1 and MGF2 is negligible - counter i runs from 0 (in MGF1) and from 1 (in MGF2)
+*F*/
+
+IPPFUN(IppStatus, ippsMGF2_rmf,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, const IppsHashMethod* pMethod))
+{
+ IPP_BAD_PTR2_RET(pMask, pMethod);
+ IPP_BADARG_RET((seedLen<0)||(maskLen<0), ippStsLengthErr);
+
+ {
+ /* hash specific */
+ int hashSize = pMethod->hashLen;
+
+ int i, outLen;
+
+ __ALIGN8 IppsHashState_rmf hashCtx;
+ ippsHashInit_rmf(&hashCtx, pMethod);
+
+ if(!pSeed)
+ seedLen = 0;
+
+ for(i=1,outLen=0; outLen<maskLen; i++) { /* counter i runs from 1 */
+ Ipp8u cnt[4];
+ cnt[0] = (Ipp8u)((i>>24) & 0xFF);
+ cnt[1] = (Ipp8u)((i>>16) & 0xFF);
+ cnt[2] = (Ipp8u)((i>>8) & 0xFF);
+ cnt[3] = (Ipp8u)(i & 0xFF);
+
+ ippsHashUpdate_rmf(pSeed, seedLen, &hashCtx);
+ ippsHashUpdate_rmf(cnt, 4, &hashCtx);
+
+ if((outLen + hashSize) <= maskLen) {
+ ippsHashFinal_rmf(pMask+outLen, &hashCtx);
+ outLen += hashSize;
+ }
+ else {
+ Ipp8u md[MAX_HASH_SIZE];
+ ippsHashFinal_rmf(md, &hashCtx);
+ CopyBlock(md, pMask+outLen, maskLen-outLen);
+ outLen = maskLen;
+ }
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_exp_bufsize.h b/ext/ipp/sources/ippcp/pcpmont_exp_bufsize.h
new file mode 100644
index 0000000..95fa88d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_exp_bufsize.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2005-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// DL over Prime Field
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpdlp.h"
+#include "pcptool.h"
+
+/*
+// Size of scratch buffer, involved in MontExp operation
+//
+// nExponents - number of exponents
+// expBitSize - (max) sizeof exponent (in bits)
+// modulusBitSize - size of modulus (bits)
+*/
+static cpSize cpMontExpScratchBufferSize(cpSize modulusBitSize, cpSize expBitSize, cpSize nExponents)
+{
+ /* sizeof table element */
+ cpSize elmDataSize = BITS_BNU_CHUNK(modulusBitSize) * sizeof(BNU_CHUNK_T);
+ /* get window_size */
+ cpSize w = (nExponents == 1) ? cpMontExp_WinSize(expBitSize) : /* use optimal window size, if single-scalar operation */
+ nExponents; /* or pseudo-oprimal if multi-scalar operation */
+
+ /* number of table entries */
+ cpSize nPrecomputed = 1 << w;
+
+ cpSize bufferSize = elmDataSize*nPrecomputed + (CACHE_LINE_SIZE - 1);
+ return bufferSize;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpmont_expbinbnu.c b/ext/ipp/sources/ippcp/pcpmont_expbinbnu.c
new file mode 100644
index 0000000..7fc2ce0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_expbinbnu.c
@@ -0,0 +1,144 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Modular Exponentiation (binary version)
+//
+// Contents:
+// cpMontExpBin_BNU()
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+
+//tbcd: temporary excluded: #include <assert.h>
+
+/*F*
+// Name: cpMontExpBin_BNU
+//
+// Purpose: computes the Montgomery exponentiation with exponent
+// BNU_CHUNK_T *dataE to the given big number integer of Montgomery form
+// BNU_CHUNK_T *dataX with respect to the modulus gsModEngine *pModEngine.
+//
+// Returns:
+// Length of modulus
+//
+//
+// Parameters:
+// dataX big number integer of Montgomery form within the
+// range [0,m-1]
+// dataE big number exponent
+// pModEngine Montgomery modulus of IppsMontState.
+/ dataY the Montgomery exponentation result.
+//
+// Notes: IppsBigNumState *r should possess enough memory space as to hold the result
+// of the operation. i.e. both pointers r->d and r->buffer should possess
+// no less than (m->n->length) number of 32-bit words.
+*F*/
+
+cpSize cpMontExpBin_BNU(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pModEngine)
+{
+ cpSize nsM = MOD_LEN( pModEngine );
+
+ /*
+ // test for special cases:
+ // x^0 = 1
+ // 0^e = 0
+ */
+ if( cpEqu_BNU_CHUNK(dataE, nsE, 0) ) {
+ COPY_BNU(dataY, MOD_MNT_R( pModEngine ), nsM);
+ }
+ else if( cpEqu_BNU_CHUNK(dataX, nsX, 0) ) {
+ ZEXPAND_BNU(dataY, 0, nsM);
+ }
+
+ /* general case */
+ else {
+ /* Montgomery engine buffers */
+ const int usedPoolLen = 1;
+ BNU_CHUNK_T* dataT = gsModPoolAlloc(pModEngine, usedPoolLen);
+ //tbcd: temporary excluded: assert(NULL!=dataT);
+
+ {
+ /* execute most significant part pE */
+ BNU_CHUNK_T eValue = dataE[nsE-1];
+ int n = cpNLZ_BNU(eValue)+1;
+
+ /* expand base and init result */
+ ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX);
+ COPY_BNU(dataY, dataT, nsM);
+
+ eValue <<= n;
+ for(; n<BNU_CHUNK_BITS; n++, eValue<<=1) {
+ /* squaring R = R*R mod Modulus */
+ MOD_METHOD( pModEngine )->sqr(dataY, dataY, pModEngine);
+
+ /* and multiply R = R*X mod Modulus */
+ if(eValue & ((BNU_CHUNK_T)1<<(BNU_CHUNK_BITS-1)))
+ MOD_METHOD( pModEngine )->mul(dataY, dataY, dataT, pModEngine);
+ }
+
+ /* execute rest bits of E */
+ for(--nsE; nsE>0; nsE--) {
+ eValue = dataE[nsE-1];
+
+ for(n=0; n<BNU_CHUNK_BITS; n++, eValue<<=1) {
+ /* squaring: R = R*R mod Modulus */
+ MOD_METHOD( pModEngine )->sqr(dataY, dataY, pModEngine);
+
+ if(eValue & ((BNU_CHUNK_T)1<<(BNU_CHUNK_BITS-1)))
+ MOD_METHOD( pModEngine )->mul(dataY, dataY, dataT, pModEngine);
+ }
+ }
+ }
+
+ gsModPoolFree(pModEngine, usedPoolLen);
+ }
+
+ return nsM;
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpmontexpbinca.c b/ext/ipp/sources/ippcp/pcpmont_expsafebinary.c
index 8c69538..2bd8153 100644
--- a/ext/ipp/sources/ippcp/src/pcpmontexpbinca.c
+++ b/ext/ipp/sources/ippcp/pcpmont_expsafebinary.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
@@ -20,7 +44,8 @@
// Cryptography Primitive.
// Modular Exponentiation (binary version)
//
-//
+// Contents:
+// cpSafeMontExp_Binary()
*/
#include "owndefs.h"
@@ -28,13 +53,24 @@
#include "pcpbn.h"
#include "pcpmontgomery.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
+/*F*
+// Name: cpSafeMontExp_Binary
+//
+// Purpose: Binary method of Exponentiation
+//
+//
+// Parameters:
+// pX big number integer of Montgomery form within the
+// range [0,m-1]
+// pE big number exponent
+// pMont Montgomery modulus of IppsMontState.
+/ pY the Montgomery exponentation result.
+//
+*F*/
-/*
-// Binary method of Exponentiation
-*/
-#if !defined(_USE_ERNIE_CBA_MITIGATION_) && !defined(_USE_GRES_CBA_MITIGATION_) // unsafe version
+#if !defined(_USE_VERSION1_CBA_MITIGATION_) && !defined(_USE_IPP_OWN_CBA_MITIGATION_) // unsafe version
void cpSafeMontExp_Binary(IppsBigNumState* pY,
const IppsBigNumState* pX, const IppsBigNumState* pE,
IppsMontState* pMont)
@@ -146,16 +182,18 @@ void cpSafeMontExp_Binary(IppsBigNumState* pY,
return;
}
}
-#endif /* _xUSE_ERNIE_CBA_MITIGATION_, _xUSE_GRES_CBA_MITIGATION_ */
+#endif /* _USE_VERSION1_CBA_MITIGATION_, _xUSE_IPP_OWN_CBA_MITIGATION_ */
-#if defined(_USE_ERNIE_CBA_MITIGATION_)
+#if defined(_USE_VERSION1_CBA_MITIGATION_)
/*
// The version below was designed according to recommendation
-// from Ernie Brickell and Mattew Wood.
+// from Crypto experts.
// The reason was to mitigate "cache monitoring" attack on RSA
// Note: this version slower than pre-mitigated version ~ 30-40%
*/
+
+
#define SET_BNU(dst,val,len) \
{ \
int n; \
@@ -168,6 +206,21 @@ void cpSafeMontExp_Binary(IppsBigNumState* pY,
for(n=0; n<(len); n++) (dst)[n] = (src1)[n] & (src2)[n]; \
}
+/*F*
+// Name: cpSafeMontExp_Binary
+//
+// Purpose: Binary method of Exponentiation
+//
+//
+// Parameters:
+// pX big number integer of Montgomery form within the
+// range [0,m-1]
+// pE big number exponent
+// pMont Montgomery modulus of IppsMontState.
+/ pY the Montgomery exponentation result.
+//
+*F*/
+
void cpSafeMontExp_Binary(IppsBigNumState* pY,
const IppsBigNumState* pX, const IppsBigNumState* pE,
IppsMontState* pMont)
@@ -308,144 +361,4 @@ void cpSafeMontExp_Binary(IppsBigNumState* pY,
BN_SIZE(pY) = ySize;
}
}
-#endif /* _USE_ERNIE_CBA_MITIGATION_ */
-
-
-#if defined(_USE_GRES_CBA_MITIGATION_)
-/*
-// The reason was to mitigate "cache monitoring" attack on RSA
-//
-// This is improved version of modular exponentiation.
-// Current version provide both either mitigation and perrformance.
-// This version in comparison with previous (IPP 4.1.3) one ~30-40% faster,
-// i.e the the performance stayed as was for pre-mitigated version
-//
-*/
-cpSize cpMontExpBin_BNU_sscm(BNU_CHUNK_T* dataY,
- const BNU_CHUNK_T* dataX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- gsModEngine* pMont)
-{
- cpSize nsM = MOD_LEN(pMont);
-
- /*
- // test for special cases:
- // x^0 = 1
- // 0^e = 0
- */
- if( cpEqu_BNU_CHUNK(dataE, nsE, 0) ) {
- COPY_BNU(dataY, MOD_MNT_R(pMont), nsM);
- }
- else if( cpEqu_BNU_CHUNK(dataX, nsX, 0) ) {
- ZEXPAND_BNU(dataY, 0, nsM);
- }
-
- /* general case */
- else {
- /* Montgomery engine buffers */
- const int usedPoolLen = 2;
- BNU_CHUNK_T* dataT = gsModPoolAlloc(pMont, usedPoolLen);
- BNU_CHUNK_T* sscmBuffer = dataT + nsM;
- //gres: temporary excluded: assert(NULL!=dataT);
-
- int back_step = 0;
-
- /* copy base */
- ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX);
- /* init result, Y=1 */
- COPY_BNU(dataY, MOD_MNT_R(pMont), nsM);
-
- /* execute bits of E */
- for(; nsE>0; nsE--) {
- BNU_CHUNK_T eValue = dataE[nsE-1];
-
- int j;
- for(j=BNU_CHUNK_BITS-1; j>=0; j--) {
- BNU_CHUNK_T mask_pattern = (BNU_CHUNK_T)(back_step-1);
-
- /* safeBuffer = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */
- int i;
- for(i=0; i<nsM; i++)
- sscmBuffer[i] = (dataY[i] & mask_pattern) | (dataT[i] & ~mask_pattern);
-
- /* squaring/multiplication: R = R*T mod Modulus */
- cpMontMul_BNU(dataY, dataY, sscmBuffer, pMont);
-
- /* update back_step and j */
- back_step = ((eValue>>j) & 0x1) & (back_step^1);
- j += back_step;
- }
- }
-
- gsModPoolFree(pMont, usedPoolLen);
- }
-
- return nsM;
-}
-#endif /* _USE_GRES_CBA_MITIGATION_ */
-
-
-cpSize cpMontExpBin_BNU(BNU_CHUNK_T* dataY,
- const BNU_CHUNK_T* dataX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- gsModEngine* pModEngine)
-{
- cpSize nsM = MOD_LEN( pModEngine );
-
- /*
- // test for special cases:
- // x^0 = 1
- // 0^e = 0
- */
- if( cpEqu_BNU_CHUNK(dataE, nsE, 0) ) {
- COPY_BNU(dataY, MOD_MNT_R( pModEngine ), nsM);
- }
- else if( cpEqu_BNU_CHUNK(dataX, nsX, 0) ) {
- ZEXPAND_BNU(dataY, 0, nsM);
- }
-
- /* general case */
- else {
- /* Montgomery engine buffers */
- const int usedPoolLen = 1;
- BNU_CHUNK_T* dataT = gsModPoolAlloc(pModEngine, usedPoolLen);
- //gres: temporary excluded: assert(NULL!=dataT);
-
- {
- /* execute most significant part pE */
- BNU_CHUNK_T eValue = dataE[nsE-1];
- int n = cpNLZ_BNU(eValue)+1;
-
- /* expand base and init result */
- ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX);
- COPY_BNU(dataY, dataT, nsM);
-
- eValue <<= n;
- for(; n<BNU_CHUNK_BITS; n++, eValue<<=1) {
- /* squaring R = R*R mod Modulus */
- MOD_METHOD( pModEngine )->sqr(dataY, dataY, pModEngine);
-
- /* and multiply R = R*X mod Modulus */
- if(eValue & ((BNU_CHUNK_T)1<<(BNU_CHUNK_BITS-1)))
- MOD_METHOD( pModEngine )->mul(dataY, dataY, dataT, pModEngine);
- }
-
- /* execute rest bits of E */
- for(--nsE; nsE>0; nsE--) {
- eValue = dataE[nsE-1];
-
- for(n=0; n<BNU_CHUNK_BITS; n++, eValue<<=1) {
- /* squaring: R = R*R mod Modulus */
- MOD_METHOD( pModEngine )->sqr(dataY, dataY, pModEngine);
-
- if(eValue & ((BNU_CHUNK_T)1<<(BNU_CHUNK_BITS-1)))
- MOD_METHOD( pModEngine )->mul(dataY, dataY, dataT, pModEngine);
- }
- }
- }
-
- gsModPoolFree(pModEngine, usedPoolLen);
- }
-
- return nsM;
-}
+#endif /* _USE_VERSION1_CBA_MITIGATION_ */ \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpmont_getsize.c b/ext/ipp/sources/ippcp/pcpmont_getsize.c
new file mode 100644
index 0000000..3fc248f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_getsize.c
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpMontGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+
+#include "pcptool.h"
+
+/*F*
+// Name: cpMontGetSize
+//
+// Purpose: Specifies size of buffer in bytes.
+//
+// Returns: Reason:
+// ippStsNoErr no errors
+//
+// Parameters:
+// poolLength length of pool
+// maxLen32 max modulus length (in Ipp32u chunks)
+// pCtxSize pointer to size of context
+//
+*F*/
+
+IppStatus cpMontGetSize(cpSize maxLen32, int poolLength, cpSize* pCtxSize)
+{
+ {
+ int size = 0;
+ int maxBitSize = maxLen32 << 5;
+ gsModEngineGetSize(maxBitSize, poolLength, &size);
+
+ *pCtxSize = sizeof(IppsMontState)
+ + (cpSize)size
+ + MONT_ALIGNMENT-1;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_init.c b/ext/ipp/sources/ippcp/pcpmont_init.c
new file mode 100644
index 0000000..7a7c4d2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_init.c
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpMontInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: cpMontInit
+//
+// Purpose: Initializes the symbolic data structure and partitions the
+// specified buffer space.
+//
+// Returns: Reason:
+// ippStsNoErr no errors
+//
+// Parameters:
+// poolLength length of pool
+// maxLen32 max modulus length (in Ipp32u chunks)
+// pMont pointer to Montgomery context
+//
+*F*/
+
+IppStatus cpMontInit(int maxLen32, int poolLength, IppsMontState* pMont)
+{
+ pMont = (IppsMontState*)( IPP_ALIGNED_PTR(pMont, MONT_ALIGNMENT) );
+ {
+ int maxBitSize = ((maxLen32) << 5);
+
+ MNT_ROOM( pMont ) = INTERNAL_BNU_LENGTH(maxLen32);
+ MNT_ENGINE ( pMont ) = (gsModEngine*)((Ipp8u*)pMont + sizeof(IppsMontState));
+
+ MNT_ID(pMont) = idCtxMontgomery;
+
+ gsModEngineInit(MNT_ENGINE(pMont), NULL, maxBitSize, poolLength, gsModArithMont());
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_multiexp_fast.c b/ext/ipp/sources/ippcp/pcpmont_multiexp_fast.c
new file mode 100644
index 0000000..5c04cf8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_multiexp_fast.c
@@ -0,0 +1,112 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// cpFastMontMultiExp()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+
+
+static cpSize GetIndex(const Ipp8u** ppE, cpSize numItems, cpSize nBit)
+{
+ cpSize shift = nBit%BYTESIZE;
+ cpSize offset= nBit/BYTESIZE;
+ cpSize index = 0;
+
+ cpSize n;
+ for(n=numItems; n>0; n--) {
+ const Ipp8u* pE = ppE[n-1] + offset;
+ Ipp8u e = pE[0];
+ index <<= 1;
+ index += (e>>shift) &1;
+ }
+ return index;
+}
+
+/*
+// Computes multi-exponentiation
+// y = x[0]^e[0] * x[1]^e[1] *...* x[numItems-1]^e[numItems-1] mod M
+//
+// Input:
+// - table pTbl of precomuted values pTbl[i] = x[0]^i[0] * x[1]^i[1] *...* x[numItems-1]^i[numItems-1] mod M,
+// where i[0], i[1], ..., i[numItems-1] are bits of i value;
+// each entry has sizeM length (i.e. equial to modulo M size)
+// - array of pointers to the BNU exponents e[0], e[1],...,e[numItems-1]
+// - pointer to the Montgomery engine
+*/
+void cpFastMontMultiExp(BNU_CHUNK_T* pY,
+ const BNU_CHUNK_T* pPrecomTbl,
+ const Ipp8u** ppE, cpSize eItemBitSize,
+ cpSize numItems,
+ gsModEngine* pModEngine)
+{
+ cpSize sizeM = MOD_LEN(pModEngine);
+
+ /* find 1-st non zero index */
+ cpSize eBitNumber;
+ cpSize tblIdx;
+ for(eBitNumber=eItemBitSize-1, tblIdx=0; !tblIdx && eBitNumber>=0; eBitNumber--)
+ tblIdx =GetIndex(ppE, numItems, eBitNumber);
+
+ COPY_BNU(pY, pPrecomTbl+tblIdx*sizeM, sizeM);
+
+ for(; eBitNumber>=0; eBitNumber--) {
+ cpMontMul_BNU(pY,
+ pY,
+ pY,
+ pModEngine);
+
+ tblIdx = GetIndex(ppE, numItems, eBitNumber);
+
+ if(tblIdx)
+ cpMontMul_BNU(pY,
+ pY,
+ pPrecomTbl+tblIdx*sizeM,
+ pModEngine);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_multiexpinitarray.c b/ext/ipp/sources/ippcp/pcpmont_multiexpinitarray.c
new file mode 100644
index 0000000..5150fdb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_multiexpinitarray.c
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
+//
+// Context:
+// cpMontMultiExpInitArray()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+//
+*/
+/*
+// Initialize multi-exponentiation computation
+// y = x[0]^e[0] * x[1]^e[1] *...* x[numItems-1]^e[numItems-1] mod M
+//
+// Output:
+// - table pTbl of precomuted values pTbl[i] = x[0]^i[0] * x[1]^i[1] *...* x[numItems-1]^i[numItems-1] mod M,
+// where i[0], i[1], ..., i[numItems-1] are bits of i value;
+//
+// Input:
+// - array of pointers to the BNU bases x[0], x[1],...,x[numItems-1]
+// - pointer to the Montgomery engine
+*/
+void cpMontMultiExpInitArray(BNU_CHUNK_T* pPrecomTbl,
+ const BNU_CHUNK_T** ppX, cpSize xItemBitSize,
+ cpSize numItems,
+ gsModEngine* pModEngine)
+{
+ cpSize sizeM = MOD_LEN(pModEngine);
+
+ cpSize i, base;
+ cpSize sizeX = BITS_BNU_CHUNK(xItemBitSize);
+
+ /* buff[0] = mont(1) */
+ COPY_BNU(pPrecomTbl, MOD_MNT_R(pModEngine), sizeM);
+ /* buff[1] = X[0] */
+ ZEXPAND_COPY_BNU(pPrecomTbl+sizeM, sizeM, ppX[0], sizeX);
+
+ for(i=1,base=2*sizeM; i<numItems; i++,base*=2) {
+ /* buf[base] = X[i] */
+ ZEXPAND_COPY_BNU(pPrecomTbl+base, sizeM, ppX[i], sizeX);
+
+ {
+ int nPasses = 1;
+ int step = base/2;
+
+ int k;
+ for(k=i-1; k>=0; k--) {
+ const BNU_CHUNK_T* pXterm = ppX[k];
+
+ BNU_CHUNK_T* pBufferBase = pPrecomTbl+base;
+ int n;
+ for(n=1; n<=nPasses; n++, pBufferBase+=2*step) {
+ cpMontMul_BNU_EX(pBufferBase+step,
+ pBufferBase, sizeM,
+ pXterm, sizeX,
+ pModEngine);
+ }
+
+ nPasses *= 2;
+ step /= 2;
+ }
+ }
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_packctx.c b/ext/ipp/sources/ippcp/pcpmont_packctx.c
new file mode 100644
index 0000000..a042e44
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_packctx.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpPackMontCtx()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: cpPackMontCtx
+//
+// Purpose: Serialize mont context
+//
+// Parameters:
+// pCtx context
+// pBuffer buffer
+*F*/
+
+void cpPackMontCtx(const IppsMontState* pCtx, Ipp8u* pBuffer)
+{
+ IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT));
+
+ /* size of context (bytes) */
+ int ctxSize = sizeof(IppsMontState);
+ CopyBlock(pCtx, pAlignedBuffer, ctxSize);
+
+ pBuffer = (Ipp8u*)pAlignedBuffer + sizeof(IppsMontState);
+
+ gsPackModEngineCtx(MNT_ENGINE(pCtx), pBuffer);
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_set.c b/ext/ipp/sources/ippcp/pcpmont_set.c
new file mode 100644
index 0000000..28b1649
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_set.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpMontSet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+
+/* Auxilirary function */
+__INLINE int cpGetBitSize(Ipp32u offset, Ipp32u val)
+{
+ int bitSize = 32;
+ if (val == 0) return 0;
+ while ((val & (1 << bitSize)) == 0) bitSize--;
+ return offset + bitSize;
+}
+
+/*F*
+// Name: cpMontSet
+//
+// Purpose: Setup modulus value
+//
+// Returns: Reason:
+// ippStsBadModulusErr (pModulus[0] & 1) == 0
+// ippStsOutOfRangeErr ((Ipp32u)MNT_ROOM(pMont) < INTERNAL_BNU_LENGTH(len32))
+// ippStsLengthErr len32<1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pModulus pointer to the modulus buffer
+// len32 length of the modulus (in Ipp32u chunks).
+// pMont pointer to the context
+*F*/
+
+IppStatus cpMontSet(const Ipp32u* pModulus, cpSize len32, IppsMontState* pMont)
+{
+ IPP_BADARG_RET(len32<1, ippStsLengthErr);
+
+ /* modulus is not an odd number */
+ IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr);
+ IPP_BADARG_RET(MNT_ROOM(pMont)<(int)(INTERNAL_BNU_LENGTH(len32)), ippStsOutOfRangeErr);
+
+ {
+ const int poolLen = MOD_MAXPOOL(MNT_ENGINE(pMont));
+ int modulusBitSize = cpGetBitSize((len32 - 1) << 5, pModulus[len32-1]);
+
+ gsModEngineInit(MNT_ENGINE(pMont), pModulus, modulusBitSize, poolLen, gsModArithMont());
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmont_unpackctx.c b/ext/ipp/sources/ippcp/pcpmont_unpackctx.c
new file mode 100644
index 0000000..9dee2a2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmont_unpackctx.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// cpUnpackMontCtx()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: cpUnpackMontCtx
+//
+// Purpose: Deserialize mont context
+//
+// Parameters:
+// pCtx context
+// pBuffer buffer
+*F*/
+
+void cpUnpackMontCtx(const Ipp8u* pBuffer, IppsMontState* pCtx)
+{
+ IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT));
+
+ /* size of context (bytes) */
+ int ctxSize = sizeof(IppsMontState);
+ CopyBlock(pAlignedBuffer, pCtx, ctxSize);
+
+ pBuffer = (Ipp8u*)pAlignedBuffer + sizeof(IppsMontState);
+
+ gsUnpackModEngineCtx(pBuffer, MNT_ENGINE(pCtx));
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontexp.c b/ext/ipp/sources/ippcp/pcpmontexp.c
new file mode 100644
index 0000000..94e217a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontexp.c
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontExp()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontExp
+//
+// Purpose: computes the Montgomery exponentiation with exponent
+// IppsBigNumState *pE to the given big number integer of Montgomery form
+// IppsBigNumState *pA with respect to the modulus IppsMontState *pCtx.
+//
+// Returns: Reason:
+// ippStsNoErr Returns no error.
+// ippStsNullPtrErr Returns an error when pointers are null.
+// ippStsBadArgErr Returns an error when a or b is a negative integer.
+// ippStsScaleRangeErr Returns an error when a or b is more than m.
+// ippStsOutOfRangeErr Returns an error when IppsBigNumState *r is larger than
+// IppsMontState *m.
+// ippStsContextMatchErr Returns an error when the context parameter does
+// not match the operation.
+//
+//
+// Parameters:
+// pA big number integer of Montgomery form within the
+// range [0,m-1]
+// pE big number exponent
+// pCtx Montgomery modulus of IppsMontState
+/ pR the Montgomery exponentation result.
+//
+// Notes: IppsBigNumState *r should possess enough memory space as to hold the result
+// of the operation. i.e. both pointers r->d and r->buffer should possess
+// no less than (m->n->length) number of 32-bit words.
+*F*/
+
+IPPFUN(IppStatus, ippsMontExp, (const IppsBigNumState* pA, const IppsBigNumState* pE, IppsMontState* pCtx, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR4_RET(pA, pE, pCtx, pR);
+
+ pCtx = (IppsMontState*)(IPP_ALIGNED_PTR((pCtx), MONT_ALIGNMENT));
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+
+ IPP_BADARG_RET(!MNT_VALID_ID(pCtx), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pE), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pCtx) ), ippStsOutOfRangeErr);
+ /* check a */
+ IPP_BADARG_RET(BN_NEGATIVE(pA), ippStsBadArgErr);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pCtx) ), MOD_LEN( MNT_ENGINE(pCtx) )) >= 0, ippStsScaleRangeErr);
+ /* check e */
+ IPP_BADARG_RET(BN_NEGATIVE(pE), ippStsBadArgErr);
+
+ cpMontExpBin_BN(pR, pA, pE, MNT_ENGINE( pCtx) );
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontexp_winsize.c b/ext/ipp/sources/ippcp/pcpmontexp_winsize.c
new file mode 100644
index 0000000..dfc0c02
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontexp_winsize.c
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright 2003-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Contents:
+// cpMontExp_WinSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "gsscramble.h"
+
+
+#if !defined(_USE_WINDOW_EXP_)
+cpSize cpMontExp_WinSize(int bitsize)
+{
+ UNREFERENCED_PARAMETER(bitsize);
+ return 1;
+}
+
+#else
+/*
+// returns (optimal) window width
+// Because of safety Window width depend on CACHE LINE size:
+// P4,EM64T, ITP - 64 bytes
+// XScale - 32 bytes
+// Blend - no cache
+*/
+#if !((_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \
+ (_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
+cpSize cpMontExp_WinSize(int bitsize)
+{
+ UNREFERENCED_PARAMETER(bitsize);
+ return 1;
+}
+#endif
+
+#if ((_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \
+ (_IPP==_IPP_S8) || (_IPP>=_IPP_G9) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E==_IPP32E_N8) || (_IPP32E>=_IPP32E_E9))
+cpSize cpMontExp_WinSize(int bitsize)
+{
+ return
+ //bitsize>3715? 8 : /*limited by 6 or 4 (LOG_CACHE_LINE_SIZE); we use it for windowing-exp imtigation */
+ //bitsize>1434? 7 :
+ #if (_IPP !=_IPP_M5)
+ bitsize> 539? 6 :
+ bitsize> 197? 5 :
+ #endif
+ bitsize> 70? 4 :
+ bitsize> 25? 3 :
+ bitsize> 9? 2 : 1;
+}
+#endif
+
+#endif /* _USE_WINDOW_EXP_ */
diff --git a/ext/ipp/sources/ippcp/pcpmontform.c b/ext/ipp/sources/ippcp/pcpmontform.c
new file mode 100644
index 0000000..8c0eb2d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontform.c
@@ -0,0 +1,112 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontForm()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontForm
+//
+// Purpose: Converts input into Montgomery domain.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx==NULL
+// pA==NULL
+// pR==NULL
+// ippStsContextMatchErr !MNT_VALID_ID(pCtx)
+// !BN_VALID_ID(pA)
+// !BN_VALID_ID(pR)
+// ippStsBadArgErr A < 0.
+// ippStsScaleRangeErr A >= Modulus.
+// ippStsOutOfRangeErr R can't hold result
+// ippStsNoErr no errors
+//
+// Parameters:
+// pA pointer to the input [0, modulus-1]
+// pCtx Montgomery context
+// pR pointer to the output (A*R mod modulus)
+*F*/
+IPPFUN(IppStatus, ippsMontForm,(const IppsBigNumState* pA, IppsMontState* pCtx, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR3_RET(pCtx, pA, pR);
+
+ pCtx = (IppsMontState*)(IPP_ALIGNED_PTR((pCtx), MONT_ALIGNMENT));
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+
+ IPP_BADARG_RET(!MNT_VALID_ID(pCtx), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_SIGN(pA) != ippBigNumPOS, ippStsBadArgErr);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pCtx) ), MOD_LEN( MNT_ENGINE(pCtx) )) >= 0, ippStsScaleRangeErr);
+ IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pCtx) ), ippStsOutOfRangeErr);
+
+ {
+ const int usedPoolLen = 1;
+ cpSize nsM = MOD_LEN( MNT_ENGINE(pCtx) );
+ BNU_CHUNK_T* pDataA = gsModPoolAlloc(MNT_ENGINE(pCtx), usedPoolLen);
+ //tbcd: temporary excluded: assert(NULL!=pDataA);
+
+ ZEXPAND_COPY_BNU(pDataA, nsM, BN_NUMBER(pA), BN_SIZE(pA));
+
+ MOD_METHOD( MNT_ENGINE(pCtx) )->encode(BN_NUMBER(pR), pDataA, MNT_ENGINE(pCtx));
+
+ FIX_BNU(BN_NUMBER(pR), nsM);
+ BN_SIZE(pR) = nsM;
+ BN_SIGN(pR) = ippBigNumPOS;
+
+ gsModPoolFree(MNT_ENGINE(pCtx), usedPoolLen);
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontget.c b/ext/ipp/sources/ippcp/pcpmontget.c
new file mode 100644
index 0000000..e8775d1
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontget.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontGet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontGet
+//
+// Purpose: Extracts modulus.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMont==NULL
+// pModulus==NULL
+// pSize==NULL
+// ippStsContextMatchErr !MNT_VALID_ID()
+// ippStsNoErr no errors
+//
+// Parameters:
+// pModulus pointer to the modulus buffer
+// pSize pointer to the modulus length (in Ipp32u chunks).
+// pMont pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsMontGet,(Ipp32u* pModulus, int* pSize, const IppsMontState* pMont))
+{
+ IPP_BAD_PTR3_RET(pMont, pModulus, pSize);
+
+ pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
+ IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
+
+ {
+ cpSize len32 = MOD_LEN(MNT_ENGINE(pMont))*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
+ Ipp32u* bnData = (Ipp32u*) MOD_MODULUS( MNT_ENGINE(pMont) );
+
+ FIX_BNU(bnData, len32);
+ COPY_BNU(pModulus, bnData, len32);
+ *pSize = len32;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontgetsize.c b/ext/ipp/sources/ippcp/pcpmontgetsize.c
new file mode 100644
index 0000000..9a48b36
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontgetsize.c
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontGetSize
+//
+// Purpose: Specifies size of buffer in bytes.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize==NULL
+// ippStsLengthErr length < 1
+// length > BITS2WORD32_SIZE(BN_MAXBITSIZE)
+// ippStsNoErr no errors
+//
+// Parameters:
+// method selected exponential method (unused parameter)
+// length max modulus length (in Ipp32u chunks)
+// pSize size of context
+//
+// Notes: Function always use method=ippBinaryMethod,
+// so this parameter is ignored
+*F*/
+IPPFUN(IppStatus, ippsMontGetSize, (IppsExpMethod method, int length, int* pSize))
+{
+ IPP_BAD_PTR1_RET(pSize);
+ IPP_BADARG_RET(length<1 || length>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
+
+ UNREFERENCED_PARAMETER(method);
+
+ {
+ return cpMontGetSize(length, MONT_DEFAULT_POOL_LENGTH, pSize);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpmontgomery.h b/ext/ipp/sources/ippcp/pcpmontgomery.h
index a33d9d5..932fe1e 100644
--- a/ext/ipp/sources/ippcp/src/pcpmontgomery.h
+++ b/ext/ipp/sources/ippcp/pcpmontgomery.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Intel(R) Integrated Performance Primitives
@@ -27,9 +51,9 @@
#include "pcpbn.h"
#include "gsmodstuff.h"
-//gres: temporary excluded: #include <assert.h>
+//tbcd: temporary excluded: #include <assert.h>
-#define MONT_DEFAULT_POOL_LENGTH 4
+#define MONT_DEFAULT_POOL_LENGTH (6)
/*
// Montgomery spec structure
@@ -91,7 +115,7 @@ __INLINE cpSize cpMontMul_BNU_EX(BNU_CHUNK_T* pR,
cpSize nsM = MOD_LEN( pModEngine );
BNU_CHUNK_T* pDataR = pR;
BNU_CHUNK_T* pDataA = gsModPoolAlloc(pModEngine, usedPoolLen);
- //gres: temporary excluded: assert(NULL!=pDataA);
+ //tbcd: temporary excluded: assert(NULL!=pDataA);
ZEXPAND_COPY_BNU(pDataA, nsM, pA, nsA);
ZEXPAND_COPY_BNU(pDataR, nsM, pB, nsB);
diff --git a/ext/ipp/sources/ippcp/pcpmontinit.c b/ext/ipp/sources/ippcp/pcpmontinit.c
new file mode 100644
index 0000000..e5dc3fa
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontinit.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontInit
+//
+// Purpose: Initializes the symbolic data structure and partitions the
+// specified buffer space.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx == NULL
+// ippStsLengthErr length < 1
+// length > BITS2WORD32_SIZE(BN_MAXBITSIZE)
+// ippStsNoErr no errors
+//
+// Parameters:
+// method selected exponential method (unused parameter)
+// length max modulus length (in Ipp32u chunks)
+// pCtx pointer to Montgomery context
+*F*/
+IPPFUN(IppStatus, ippsMontInit,(IppsExpMethod method, int length, IppsMontState* pCtx))
+{
+ IPP_BADARG_RET(length<1 || length>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
+
+ IPP_BAD_PTR1_RET(pCtx);
+
+ UNREFERENCED_PARAMETER(method);
+
+ {
+ return cpMontInit(length, MONT_DEFAULT_POOL_LENGTH, pCtx);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontmul.c b/ext/ipp/sources/ippcp/pcpmontmul.c
new file mode 100644
index 0000000..71c232c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontmul.c
@@ -0,0 +1,123 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontMul()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontMul
+//
+// Purpose: Computes Montgomery modular multiplication for positive big
+// number integers of Montgomery form. The following pseudocode
+// represents this function:
+// r <- ( a * b * R^(-1) ) mod m
+//
+// Returns: Reason:
+// ippStsNoErr Returns no error.
+// ippStsNullPtrErr Returns an error when pointers are null.
+// ippStsBadArgErr Returns an error when a or b is a negative integer.
+// ippStsScaleRangeErr Returns an error when a or b is more than m.
+// ippStsOutOfRangeErr Returns an error when IppsBigNumState *r is larger than
+// IppsMontState *m.
+// ippStsContextMatchErr Returns an error when the context parameter does
+// not match the operation.
+//
+// Parameters:
+// pA Multiplicand within the range [0, m - 1].
+// pB Multiplier within the range [0, m - 1].
+// pCtx Modulus.
+// pR Montgomery multiplication result.
+//
+// Notes: The size of IppsBigNumState *r should not be less than the data
+// length of the modulus m.
+*F*/
+IPPFUN(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* pCtx, IppsBigNumState* pR))
+{
+ IPP_BAD_PTR4_RET(pA, pB, pCtx, pR);
+
+ pCtx = (IppsMontState*)(IPP_ALIGNED_PTR((pCtx), MONT_ALIGNMENT));
+ pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
+ pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
+ pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
+
+ IPP_BADARG_RET(!MNT_VALID_ID(pCtx), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
+ IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(BN_NEGATIVE(pA) || BN_NEGATIVE(pB), ippStsBadArgErr);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pCtx) ), MOD_LEN( MNT_ENGINE(pCtx) )) >= 0, ippStsScaleRangeErr);
+ IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pB), BN_SIZE(pB), MOD_MODULUS( MNT_ENGINE(pCtx) ), MOD_LEN( MNT_ENGINE(pCtx) )) >= 0, ippStsScaleRangeErr);
+ IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pCtx) ), ippStsOutOfRangeErr);
+
+ {
+ const int usedPoolLen = 2;
+ cpSize nsM = MOD_LEN( MNT_ENGINE(pCtx) );
+ BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
+ BNU_CHUNK_T* pDataA = gsModPoolAlloc(MNT_ENGINE(pCtx), usedPoolLen);
+ BNU_CHUNK_T* pDataB = pDataA + nsM;
+ //tbcd: temporary excluded: assert(NULL!=pDataA);
+
+ ZEXPAND_COPY_BNU(pDataA, nsM, BN_NUMBER(pA), BN_SIZE(pA));
+ ZEXPAND_COPY_BNU(pDataB, nsM, BN_NUMBER(pB), BN_SIZE(pB));
+
+ MOD_METHOD( MNT_ENGINE(pCtx) )->mul(pDataR, pDataA, pDataB, MNT_ENGINE(pCtx));
+
+ gsModPoolFree(MNT_ENGINE(pCtx), usedPoolLen);
+
+ FIX_BNU(pDataR, nsM);
+ BN_SIZE(pR) = nsM;
+ BN_SIGN(pR) = ippBigNumPOS;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpmontred.c b/ext/ipp/sources/ippcp/pcpmontred.c
new file mode 100644
index 0000000..dc9fe25
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontred.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2010-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+*/
+
+#include "owncp.h"
+#include "pcpbnuarith.h"
+
+
+#if defined(_USE_C_cpMontRedAdc_BNU_)
+#pragma message ("C version of cpMontRedAdc_BNU: ON")
+#else
+#pragma message ("C version of cpMontRedAdc_BNU: OFF")
+#endif
+
+#if !((_IPP==_IPP_W7) || \
+ (_IPP==_IPP_T7) || \
+ (_IPP==_IPP_V8) || \
+ (_IPP==_IPP_P8) || \
+ (_IPP>=_IPP_G9) || \
+ (_IPP==_IPP_S8) || \
+ (_IPP32E==_IPP32E_M7) || \
+ (_IPP32E==_IPP32E_U8) || \
+ (_IPP32E==_IPP32E_Y8) || \
+ (_IPP32E>=_IPP32E_E9) || \
+ (_IPP32E==_IPP32E_N8)) || \
+ defined(_USE_C_cpMontRedAdc_BNU_)
+#define cpMontRedAdc_BNU OWNAPI(cpMontRedAdc_BNU)
+void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
+ BNU_CHUNK_T* pProduct,
+ const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
+{
+ BNU_CHUNK_T carry;
+ BNU_CHUNK_T extension;
+
+ cpSize n;
+ for(n=0, carry = 0; n<(nsM-1); n++) {
+ BNU_CHUNK_T u = pProduct[n]*m0;
+ BNU_CHUNK_T t = pProduct[nsM +n +1] + carry;
+
+ extension = cpAddMulDgt_BNU(pProduct+n, pModulus, nsM, u);
+ ADD_AB(carry, pProduct[nsM+n], pProduct[nsM+n], extension);
+ t += carry;
+
+ carry = t<pProduct[nsM+n+1];
+ pProduct[nsM+n+1] = t;
+ }
+
+ m0 *= pProduct[nsM-1];
+ extension = cpAddMulDgt_BNU(pProduct+nsM-1, pModulus, nsM, m0);
+ ADD_AB(extension, pProduct[2*nsM-1], pProduct[2*nsM-1], extension);
+
+ carry |= extension;
+ carry -= cpSub_BNU(pR, pProduct+nsM, pModulus, nsM);
+ /* condition copy: R = carry? Product+mSize : R */
+ MASKED_COPY_BNU(pR, carry, pProduct+nsM, pR, nsM);
+}
+#endif
diff --git a/ext/ipp/sources/ippcp/pcpmontred.h b/ext/ipp/sources/ippcp/pcpmontred.h
new file mode 100644
index 0000000..8b65258
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontred.h
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+*/
+#if !defined(_CP_MONTRED_H)
+#define _CP_MONTRED_H
+
+#include "owndefs.h"
+#include "owncp.h"
+
+#include "pcpbnuimpl.h"
+/*
+// Montgomery reduction
+*/
+#define cpMontRedAdc_BNU OWNAPI(cpMontRedAdc_BNU)
+void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
+ BNU_CHUNK_T* pProduct,
+ const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0);
+
+#define cpMontRedAdx_BNU OWNAPI(cpMontRedAdx_BNU)
+void cpMontRedAdx_BNU(BNU_CHUNK_T* pR,
+ BNU_CHUNK_T* pProduct,
+ const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0);
+
+__INLINE void cpMontRed_BNU_opt(BNU_CHUNK_T* pR,
+ BNU_CHUNK_T* pProduct,
+ const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
+{
+#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_)
+ cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0);
+#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ IsFeatureEnabled(ippCPUID_ADCOX)? cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0)
+ : cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0);
+#else
+ cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0);
+#endif
+}
+
+#endif /* _CP_MONTRED_H */
diff --git a/ext/ipp/sources/ippcp/pcpmontset.c b/ext/ipp/sources/ippcp/pcpmontset.c
new file mode 100644
index 0000000..61bf3b5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpmontset.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Contents:
+// ippsMontSet()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsMontSet
+//
+// Purpose: Setup modulus value
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx == NULL
+// pModulus == NULL
+// ippStsContextMatchErr !MNT_VALID_ID(pCtx)
+// ippStsBadModulusErr (pModulus[0] & 1) == 0
+// ippStsOutOfRangeErr ((Ipp32u)MNT_ROOM(pCtx) < INTERNAL_BNU_LENGTH(size))
+// ippStsLengthErr size<1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pModulus pointer to the modulus buffer
+// size length of the modulus (in Ipp32u chunks).
+// pCtx pointer to the context
+*F*/
+
+IPPFUN(IppStatus, ippsMontSet,(const Ipp32u* pModulus, int size, IppsMontState* pCtx))
+{
+ IPP_BAD_PTR2_RET(pModulus, pCtx);
+ pCtx = (IppsMontState*)(IPP_ALIGNED_PTR((pCtx), MONT_ALIGNMENT));
+ IPP_BADARG_RET(!MNT_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ IPP_BADARG_RET(size<1, ippStsLengthErr);
+
+ /* modulus is not an odd number */
+ IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr);
+ IPP_BADARG_RET(((Ipp32u)MNT_ROOM(pCtx) < INTERNAL_BNU_LENGTH(size)), ippStsOutOfRangeErr);
+
+ {
+ return cpMontSet(pModulus, size, pCtx);
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpname.h b/ext/ipp/sources/ippcp/pcpname.h
new file mode 100644
index 0000000..b2b87c2
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpname.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+*/
+
+#ifndef __PCPNAME_H__
+#define __PCPNAME_H__
+
+/*
+ The prefix of library without the quotes. The prefix is directly used to generate the
+ GetLibVersion function. It is used to generate the names in the dispatcher code, in
+ the version description and in the resource file.
+*/
+#define LIB_PREFIX ippcp
+
+/*
+ Names of library. It is used in the resource file and is used to generate the names
+ in the dispatcher code.
+*/
+#define IPP_LIB_LONGNAME() "Cryptography"
+#define IPP_LIB_SHORTNAME() "ippCP"
+
+
+#define GET_STR2(x) #x
+#define GET_STR(x) GET_STR2(x)
+#define IPP_LIB_PREFIX() GET_STR(LIB_PREFIX)
+
+#define IPP_INC_NAME() "ippcp.h"
+
+#endif /* __PCPNAME_H__ */
+/* ///////////////////////// End of file "pcpname.h" ///////////////////////// */
diff --git a/ext/ipp/sources/ippcp/pcpngmontexpstuff.h b/ext/ipp/sources/ippcp/pcpngmontexpstuff.h
new file mode 100644
index 0000000..2a017ee
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngmontexpstuff.h
@@ -0,0 +1,188 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal ng RSA Function Prototypes
+//
+//
+*/
+
+#if !defined(_CP_NG_MONT_EXP_STUFF_H)
+#define _CP_NG_MONT_EXP_STUFF_H
+
+#include "pcpbnuimpl.h"
+#include "pcpbn.h"
+#include "gsmodstuff.h"
+
+
+/*
+// optimal size of fixed window exponentiation
+*/
+__INLINE cpSize gsMontExp_WinSize(cpSize bitsize)
+{
+ #if defined(_USE_WINDOW_EXP_)
+ // new computations
+ return
+ #if (_IPP !=_IPP_M5) /*limited by 6 or 4 (LOG_CACHE_LINE_SIZE); we use it for windowing-exp imtigation */
+ bitsize> 4096? 6 : /* 4096- .. . */
+ bitsize> 2666? 5 : /* 2666 - 4095 */
+ #endif
+ bitsize> 717? 4 : /* 717 - 2665 */
+ bitsize> 178? 3 : /* 178 - 716 */
+ bitsize> 41? 2 : 1; /* 41 - 177 */
+ #else
+ UNREFERENCED_PARAMETER(bitsize);
+ return 1;
+ #endif
+}
+
+/*
+// Montgomery encoding/decoding
+*/
+__INLINE cpSize gsMontEnc_BNU(BNU_CHUNK_T* pR,
+ const BNU_CHUNK_T* pXreg, cpSize nsX,
+ const gsModEngine* pMont)
+{
+ cpSize nsM = MOD_LEN( pMont );
+ ZEXPAND_COPY_BNU(pR, nsM, pXreg, nsX);
+ MOD_METHOD( pMont )->encode(pR, pR, (gsModEngine*)pMont);
+ return nsM;
+}
+
+__INLINE cpSize gsMontDec_BNU(BNU_CHUNK_T* pR,
+ const BNU_CHUNK_T* pXmont,
+ gsModEngine* pMont)
+{
+ cpSize nsM = MOD_LEN(pMont);
+ MOD_METHOD( pMont )->decode(pR, pXmont, (gsModEngine*)pMont);
+ return nsM;
+}
+
+__INLINE void gsMontEnc_BN(IppsBigNumState* pRbn,
+ const IppsBigNumState* pXbn,
+ gsModEngine* pMont)
+{
+ BNU_CHUNK_T* pR = BN_NUMBER(pRbn);
+ cpSize nsM = MOD_LEN(pMont);
+
+ gsMontEnc_BNU(pR, BN_NUMBER(pXbn), BN_SIZE(pXbn), pMont);
+
+ FIX_BNU(pR, nsM);
+ BN_SIZE(pRbn) = nsM;
+ BN_SIGN(pRbn) = ippBigNumPOS;
+}
+
+
+/* exponentiation buffer size */
+#define gsMontExpBinBuffer OWNAPI(gsMontExpBinBuffer)
+#define gsMontExpWinBuffer OWNAPI(gsMontExpWinBuffer)
+cpSize gsMontExpBinBuffer(int modulusBits);
+cpSize gsMontExpWinBuffer(int modulusBits);
+
+/* exponentiation prototype */
+typedef cpSize (*ngMontExp)(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+/*
+// "fast" and "safe" binary montgomery exponentiation ("fast" version)
+*/
+#define gsMontExpBin_BNU OWNAPI(gsMontExpBin_BNU)
+#define gsModExpBin_BNU OWNAPI(gsModExpBin_BNU)
+cpSize gsMontExpBin_BNU(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+cpSize gsModExpBin_BNU(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpBin_BNU_sscm OWNAPI(gsMontExpBin_BNU_sscm)
+#define gsModExpBin_BNU_sscm OWNAPI(gsModExpBin_BNU_sscm)
+cpSize gsMontExpBin_BNU_sscm(BNU_CHUNK_T* pY,
+ const BNU_CHUNK_T* pX, cpSize nsX,
+ const BNU_CHUNK_T* pE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+cpSize gsModExpBin_BNU_sscm(BNU_CHUNK_T* pY,
+ const BNU_CHUNK_T* pX, cpSize nsX,
+ const BNU_CHUNK_T* pE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+/*
+// "fast" and "safe" fixed-size window montgomery exponentiation
+*/
+#define gsMontExpWin_BNU OWNAPI(gsMontExpWin_BNU_mont)
+#define gsModExpWin_BNU OWNAPI(gsModExpWin_BNU)
+cpSize gsMontExpWin_BNU(BNU_CHUNK_T* pY,
+ const BNU_CHUNK_T* pX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+cpSize gsModExpWin_BNU(BNU_CHUNK_T* pY,
+ const BNU_CHUNK_T* pX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpWin_BNU_sscm OWNAPI(gsMontExpWin_BNU_mont_sscm)
+#define gsModExpWin_BNU_sscm OWNAPI(gsModExpWin_BNU_sscm)
+cpSize gsMontExpWin_BNU_sscm(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+cpSize gsModExpWin_BNU_sscm(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nbitsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#endif /* _CP_NG_MONT_EXP_STUFF_H */
diff --git a/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx2.h b/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx2.h
new file mode 100644
index 0000000..bf52af4
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx2.h
@@ -0,0 +1,142 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions of AVX2 Montgomery Exp
+//
+*/
+#include "owncp.h"
+
+#if (_IPP32E>=_IPP32E_L9)
+
+#include "pcpbnuimpl.h"
+#include "pcpngmontexpstuff.h"
+
+#define RSA_AVX2_MIN_BITSIZE (1024)
+#define RSA_AVX2_MAX_BITSIZE (13*1024)
+
+#define NORM_DIGSIZE_AVX2 (BITSIZE(Ipp32u))
+#define NORM_BASE_AVX2 ((Ipp64u)1<<NORM_DIGSIZE_AVX2)
+#define NORM_MASK_AVX2 (NORM_BASE_AVX2-1)
+
+#define EXP_DIGIT_SIZE_AVX2 (27)
+#define EXP_DIGIT_BASE_AVX2 (1<<EXP_DIGIT_SIZE_AVX2)
+#define EXP_DIGIT_MASK_AVX2 (EXP_DIGIT_BASE_AVX2-1)
+
+
+/* number of "diSize" chunks in "bitSize" bit string */
+__INLINE int cpDigitNum_avx2(int bitSize, int digSize)
+{ return (bitSize + digSize-1)/digSize; }
+
+/* number of "EXP_DIGIT_SIZE_AVX2" chunks in "bitSize" bit string matched for AMM */
+__INLINE cpSize numofVariable_avx2(int modulusBits)
+{
+ cpSize ammBitSize = 2 + cpDigitNum_avx2(modulusBits, BITSIZE(BNU_CHUNK_T)) * BITSIZE(BNU_CHUNK_T);
+ cpSize redNum = cpDigitNum_avx2(ammBitSize, EXP_DIGIT_SIZE_AVX2);
+ return redNum;
+}
+
+/* buffer corresponding to numofVariable_avx2() */
+__INLINE cpSize numofVariableBuff_avx2(int numV)
+{
+ return numV +4;
+}
+
+/* basic operations */
+#define cpMontMul1024_avx2 OWNAPI(cpMontMul1024_avx2)
+void cpMontMul1024_avx2(Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pB, const Ipp64u* pModulus, int mLen, Ipp64u m0);
+#define cpMontMul4n_avx2 OWNAPI(cpMontMul4n_avx2)
+void cpMontMul4n_avx2 (Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pB, const Ipp64u* pModulus, int mLen, Ipp64u m0, Ipp64u* pScratchBuffer);
+#define cpMontMul4n1_avx2 OWNAPI(cpMontMul4n1_avx2)
+void cpMontMul4n1_avx2 (Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pB, const Ipp64u* pModulus, int mLen, Ipp64u m0, Ipp64u* pScratchBuffer);
+#define cpMontMul4n2_avx2 OWNAPI(cpMontMul4n2_avx2)
+void cpMontMul4n2_avx2 (Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pB, const Ipp64u* pModulus, int mLen, Ipp64u m0, Ipp64u* pScratchBuffer);
+#define cpMontMul4n3_avx2 OWNAPI(cpMontMul4n3_avx2)
+void cpMontMul4n3_avx2 (Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pB, const Ipp64u* pModulus, int mLen, Ipp64u m0, Ipp64u* pScratchBuffer);
+
+#define cpMontSqr1024_avx2 OWNAPI(cpMontSqr1024_avx2)
+void cpMontSqr1024_avx2(Ipp64u* pR, const Ipp64u* pA, const Ipp64u* pModulus, int mLen, Ipp64u k0, Ipp64u* pBuffer);
+#define cpSqr1024_avx2 OWNAPI(cpSqr1024_avx2)
+void cpSqr1024_avx2 (Ipp64u* pR, const Ipp64u* pA, int aLen, Ipp64u* pBuffer);
+#define cpSqr_avx2 OWNAPI(cpSqr_avx2)
+void cpSqr_avx2 (Ipp64u* pR, const Ipp64u* pA, int aLen, Ipp64u* pBuffer);
+
+#define cpMontRed_avx2 OWNAPI(cpMontRed_avx2)
+void cpMontRed_avx2(Ipp64u* pR, Ipp64u* pProduct, const Ipp64u* pModulus, int mLen, Ipp64u k0);
+
+/* exponentiation buffer size */
+#define gsMontExpBinBuffer_avx2 OWNAPI(gsMontExpBinBuffer_avx2)
+#define gsMontExpWinBuffer_avx2 OWNAPI(gsMontExpWinBuffer_avx2)
+cpSize gsMontExpBinBuffer_avx2(int modulusBits);
+cpSize gsMontExpWinBuffer_avx2(int modulusBits);
+
+/* AVX2 exponentiations */
+#define gsMontExpBin_BNU_avx2 OWNAPI(gsMontExpBin_BNU_avx2)
+cpSize gsMontExpBin_BNU_avx2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpBin_BNU_sscm_avx2 OWNAPI(gsMontExpBin_BNU_sscm_avx2)
+cpSize gsMontExpBin_BNU_sscm_avx2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpWin_BNU_avx2 OWNAPI(gsMontExpWin_BNU_avx2)
+cpSize gsMontExpWin_BNU_avx2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpWin_BNU_sscm_avx2 OWNAPI(gsMontExpWin_BNU_sscm_avx2)
+cpSize gsMontExpWin_BNU_sscm_avx2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#endif /* _IPP32E_L9 */
diff --git a/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx512.h b/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx512.h
new file mode 100644
index 0000000..72a1c30
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngmontexpstuff_avx512.h
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions of AVX512 Montgomery Exp
+//
+*/
+#include "owncp.h"
+
+#if (_IPP32E>=_IPP32E_K0)
+
+#include "pcpbnuimpl.h"
+#include "pcpngmontexpstuff.h"
+
+#define RSA_AVX512_MIN_BITSIZE (1024)
+#define RSA_AVX512_MAX_BITSIZE (13*1024)
+
+#define NORM_DIGSIZE_AVX512 (BITSIZE(Ipp64u))
+#define NORM_BASE_AVX512 ((Ipp64u)1<<NORM_DIGSIZE_AVX512)
+#define NORM_MASK_AVX512 (NORM_BASE_AVX512-1)
+
+#define EXP_DIGIT_SIZE_AVX512 (52)
+#define EXP_DIGIT_BASE_AVX512 (1<<EXP_DIGIT_SIZE_AVX512)
+#define EXP_DIGIT_MASK_AVX512 ((Ipp64u)0xFFFFFFFFFFFFF)
+
+/* number of digits */
+__INLINE int cpDigitNum_avx512(int bitSize, int digSize)
+{ return (bitSize + digSize-1)/digSize; }
+
+/* number of "EXP_DIGIT_SIZE_AVX512" chunks in "bitSize" bit string matched for AMM */
+__INLINE cpSize numofVariable_avx512(int modulusBits)
+{
+ cpSize ammBitSize = 2 + cpDigitNum_avx512(modulusBits, BITSIZE(BNU_CHUNK_T)) * BITSIZE(BNU_CHUNK_T);
+ cpSize redNum = cpDigitNum_avx512(ammBitSize, EXP_DIGIT_SIZE_AVX512);
+ return redNum;
+}
+
+/* buffer corresponding to numofVariable_avx2() */
+/* cpMontExp_avx512_BufferSize() */
+__INLINE int numofVariableBuff_avx512(int len)
+{
+ int tail = len%8;
+ if(0==tail) tail = 8;
+ return len + (8-tail);
+}
+
+/* exponentiation buffer size */
+#define gsMontExpBinBuffer_avx512 OWNAPI(gsMontExpBinBuffer_avx512)
+#define gsMontExpWinBuffer_avx512 OWNAPI(gsMontExpWinBuffer_avx512)
+cpSize gsMontExpBinBuffer_avx512(int modulusBits);
+cpSize gsMontExpWinBuffer_avx512(int modulusBits);
+
+/* exponentiations */
+#define gsMontExpBin_BNU_avx512 OWNAPI(gsMontExpBin_BNU_avx512)
+cpSize gsMontExpBin_BNU_avx512(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpWin_BNU_avx512 OWNAPI(gsMontExpWin_BNU_avx512)
+cpSize gsMontExpWin_BNU_avx512(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpBin_BNU_sscm_avx512 OWNAPI(gsMontExpBin_BNU_sscm_avx512)
+cpSize gsMontExpBin_BNU_sscm_avx512(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#define gsMontExpWin_BNU_sscm_avx512 OWNAPI(gsMontExpWin_BNU_sscm_avx512)
+cpSize gsMontExpWin_BNU_sscm_avx512(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#endif /* _IPP32E_K0 */
diff --git a/ext/ipp/sources/ippcp/pcpngmontexpstuff_sse2.h b/ext/ipp/sources/ippcp/pcpngmontexpstuff_sse2.h
new file mode 100644
index 0000000..a25ae67
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngmontexpstuff_sse2.h
@@ -0,0 +1,120 @@
+/*******************************************************************************
+* Copyright 2016-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions of SSE Montgomery Exp
+//
+*/
+#include "owncp.h"
+
+#if (_IPP>=_IPP_W7)
+
+#include "pcpbnuimpl.h"
+#include "pcpngmontexpstuff.h"
+
+#define RSA_SSE2_MIN_BITSIZE (256)
+#define RSA_SSE2_MAX_BITSIZE (13*1024)
+
+#define NORM_DIGSIZE_SSE2 (BITSIZE(Ipp32u))
+#define NORM_BASE_SSE2 ((Ipp64u)1<<NORM_DIGSIZE_SSE2)
+#define NORM_MASK_SSE2 (NORM_BASE_SSE2-1)
+
+#define EXP_DIGIT_SIZE_SSE2 (27)
+#define EXP_DIGIT_BASE_SSE2 (1<<EXP_DIGIT_SIZE_SSE2)
+#define EXP_DIGIT_MASK_SSE2 (EXP_DIGIT_BASE_SSE2-1)
+
+
+/* number of "diSize" chunks in "bitSize" bit string */
+__INLINE int cpDigitNum_sse2(int bitSize, int digSize)
+{ return (bitSize + digSize-1)/digSize; }
+
+/* number of "RSA_SSE2_DIGIT_SIZE" chunks in "bitSize" bit string matched for AMM */
+__INLINE cpSize numofVariable_sse2(int modulusBits)
+{
+ cpSize ammBitSize = 2 + cpDigitNum_sse2(modulusBits, BITSIZE(BNU_CHUNK_T)) * BITSIZE(BNU_CHUNK_T);
+ cpSize redNum = cpDigitNum_sse2(ammBitSize, EXP_DIGIT_SIZE_SSE2);
+ return redNum;
+}
+
+/* buffer corresponding to numofVariable_sse2() */
+__INLINE cpSize numofVariableBuff_sse2(int numV)
+{
+ return numV +4 +(numV&1);
+}
+
+/* exponentiation buffer size */
+#define gsMontExpBinBuffer_sse2 OWNAPI(gsMontExpBinBuffer_sse2)
+#define gsMontExpWinBuffer_sse2 OWNAPI(gsMontExpWinBuffer_sse2)
+cpSize gsMontExpBinBuffer_sse2(int modulusBits);
+cpSize gsMontExpWinBuffer_sse2(int modulusBits);
+
+/* exponentiations */
+#define gsMontExpBin_BNU_sse2 OWNAPI(gsMontExpBin_BNU_sse2)
+cpSize gsMontExpBin_BNU_sse2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBufferT);
+
+#define gsMontExpBin_BNU_sscm_sse2 OWNAPI(gsMontExpBin_BNU_sscm_sse2)
+cpSize gsMontExpBin_BNU_sscm_sse2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBufferT);
+
+#define gsMontExpWin_BNU_sse2 OWNAPI(gsMontExpWin_BNU_sse2)
+cpSize gsMontExpWin_BNU_sse2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBufferT);
+
+#define gsMontExpWin_BNU_sscm_sse2 OWNAPI(gsMontExpWin_BNU_sscm_sse2)
+cpSize gsMontExpWin_BNU_sscm_sse2(BNU_CHUNK_T* dataY,
+ const BNU_CHUNK_T* dataX, cpSize nsX,
+ const BNU_CHUNK_T* dataE, cpSize nsE,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer);
+
+#endif /* _IPP_W7 */
diff --git a/ext/ipp/sources/ippcp/pcpngrsa.h b/ext/ipp/sources/ippcp/pcpngrsa.h
new file mode 100644
index 0000000..6dbdfe3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngrsa.h
@@ -0,0 +1,145 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal ng RSA Function Prototypes
+//
+//
+*/
+
+#if !defined(_CP_NG_RSA_H)
+#define _CP_NG_RSA_H
+
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+#include "pcpngmontexpstuff.h"
+
+struct _cpRSA_public_key {
+ IppCtxId id; /* key ID */
+ int maxbitSizeN;
+ int maxbitSizeE;
+ int bitSizeN; /* RSA modulus bitsize */
+ int bitSizeE; /* RSA public exp bitsize */
+
+ BNU_CHUNK_T* pDataE; /* public exp */
+ gsModEngine* pMontN; /* montgomery engine (N) */
+};
+
+/* access */
+#define RSA_PUB_KEY_MAXSIZE_N(x) ((x)->maxbitSizeN)
+#define RSA_PUB_KEY_MAXSIZE_E(x) ((x)->maxbitSizeE)
+#define RSA_PUB_KEY_ID(x) ((x)->id)
+#define RSA_PUB_KEY_BITSIZE_N(x) ((x)->bitSizeN)
+#define RSA_PUB_KEY_BITSIZE_E(x) ((x)->bitSizeE)
+#define RSA_PUB_KEY_E(x) ((x)->pDataE)
+#define RSA_PUB_KEY_NMONT(x) ((x)->pMontN)
+#define RSA_PUB_KEY_VALID_ID(x) (RSA_PUB_KEY_ID((x))==idCtxRSA_PubKey)
+#define RSA_PUB_KEY_IS_SET(x) (RSA_PUB_KEY_BITSIZE_N((x))>0)
+
+/* alignment */
+#define RSA_PUBLIC_KEY_ALIGNMENT ((int)(sizeof(void*)))
+
+struct _cpRSA_private_key {
+ IppCtxId id; /* key ID */
+ int maxbitSizeN;
+ int maxbitSizeD;
+ int bitSizeN; /* RSA modulus bitsize */
+ int bitSizeD; /* RSA private exp bitsize */
+ int bitSizeP; /* RSA p-factor bitsize */
+ int bitSizeQ; /* RSA q-factor bitsize */
+
+ BNU_CHUNK_T* pDataD; /* private exp */
+ BNU_CHUNK_T* pDataDp; /* dp private exp */
+ BNU_CHUNK_T* pDataDq; /* dq private exp */
+ BNU_CHUNK_T* pDataQinv; /* qinv coeff */
+
+ gsModEngine* pMontP; /* montgomery engine (P) */
+ gsModEngine* pMontQ; /* montgomery engine (Q) */
+ gsModEngine* pMontN; /* montgomery engine (N) */
+};
+
+/* access */
+#define RSA_PRV_KEY_MAXSIZE_N(x) ((x)->maxbitSizeN)
+#define RSA_PRV_KEY_MAXSIZE_D(x) ((x)->maxbitSizeD)
+#define RSA_PRV_KEY_ID(x) ((x)->id)
+#define RSA_PRV_KEY_BITSIZE_N(x) ((x)->bitSizeN)
+#define RSA_PRV_KEY_BITSIZE_D(x) ((x)->bitSizeD)
+#define RSA_PRV_KEY_BITSIZE_P(x) ((x)->bitSizeP)
+#define RSA_PRV_KEY_BITSIZE_Q(x) ((x)->bitSizeQ)
+#define RSA_PRV_KEY_D(x) ((x)->pDataD)
+#define RSA_PRV_KEY_DP(x) ((x)->pDataDp)
+#define RSA_PRV_KEY_DQ(x) ((x)->pDataDq)
+#define RSA_PRV_KEY_INVQ(x) ((x)->pDataQinv)
+#define RSA_PRV_KEY_PMONT(x) ((x)->pMontP)
+#define RSA_PRV_KEY_QMONT(x) ((x)->pMontQ)
+#define RSA_PRV_KEY_NMONT(x) ((x)->pMontN)
+#define RSA_PRV_KEY1_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey1)
+#define RSA_PRV_KEY2_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey2)
+#define RSA_PRV_KEY_VALID_ID(x) (RSA_PRV_KEY1_VALID_ID((x)) || RSA_PRV_KEY2_VALID_ID((x)))
+#define RSA_PRV_KEY_IS_SET(x) (RSA_PRV_KEY_BITSIZE_N((x))>0)
+
+/* alignment */
+#define RSA_PRIVATE_KEY_ALIGNMENT ((int)(sizeof(void*)))
+
+#define MOD_ENGINE_RSA_POOL_SIZE (2)
+
+/*
+// Montgomery engine preparation (GetSize/init/Set)
+*/
+#define rsaMontExpGetSize OWNAPI(rsaMontExpGetSize)
+void rsaMontExpGetSize(int length, int* pSize);
+
+/*
+// pubic and private key operations
+*/
+#define gsRSApub_cipher OWNAPI(gsRSApub_cipher)
+void gsRSApub_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPublicKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
+
+#define gsRSAprv_cipher OWNAPI(gsRSAprv_cipher)
+void gsRSAprv_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
+
+#define gsRSAprv_cipher_crt OWNAPI(gsRSAprv_cipher_crt)
+void gsRSAprv_cipher_crt(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
+
+#endif /* _CP_NG_RSA_H */
diff --git a/ext/ipp/sources/ippcp/pcpngrsamethod.h b/ext/ipp/sources/ippcp/pcpngrsamethod.h
new file mode 100644
index 0000000..6637436
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpngrsamethod.h
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal ng RSA methods
+*/
+
+#if !defined(_CP_NG_RSA_METHOD_H)
+#define _CP_NG_RSA_METHOD_H
+
+#include "pcpngmontexpstuff.h"
+
+/*
+// declaration of RSA exponentiation
+*/
+typedef cpSize (*ngBufNum)(int modulusBits);
+
+typedef struct _gsMethod_RSA {
+ int loModulusBisize; // application area (lowew
+ int hiModulusBisize; // and upper)
+ ngBufNum bufferNumFunc; // pub operation buffer in BNU_CHUNK_T
+ ngMontExp expFun; // exponentiation
+} gsMethod_RSA;
+
+
+/* GPR exponentiation */
+#define gsMethod_RSA_gpr_public OWNAPI(gsMethod_RSA_gpr_public)
+#define gsMethod_RSA_gpr_private OWNAPI(gsMethod_RSA_gpr_private)
+gsMethod_RSA* gsMethod_RSA_gpr_public(void);
+gsMethod_RSA* gsMethod_RSA_gpr_private(void);
+
+
+/* SSE2 exponentiation */
+#if (_IPP>=_IPP_W7)
+#define gsMethod_RSA_sse2_public OWNAPI(gsMethod_RSA_sse2_public)
+#define gsMethod_RSA_sse2_private OWNAPI(gsMethod_RSA_sse2_private)
+gsMethod_RSA* gsMethod_RSA_sse2_public(void);
+gsMethod_RSA* gsMethod_RSA_sse2_private(void);
+#endif /* _IPP_W7 */
+
+/* AVX2 exponentiation */
+#if (_IPP32E>=_IPP32E_L9)
+#define gsMethod_RSA_avx2_public OWNAPI(gsMethod_RSA_avx2_public)
+#define gsMethod_RSA_avx2_private OWNAPI(gsMethod_RSA_avx2_private)
+gsMethod_RSA* gsMethod_RSA_avx2_public(void);
+gsMethod_RSA* gsMethod_RSA_avx2_private(void);
+#endif /* _IPP32E_L9 */
+
+/* AVX512 exponentiation */
+#if (_IPP32E>=_IPP32E_K0)
+#define gsMethod_RSA_avx512_public OWNAPI(gsMethod_RSA_avx512_public)
+#define gsMethod_RSA_avx512_private OWNAPI(gsMethod_RSA_avx512_private)
+gsMethod_RSA* gsMethod_RSA_avx512_public(void);
+gsMethod_RSA* gsMethod_RSA_avx512_private(void);
+#endif /* _IPP32E_K0 */
+
+#endif /* _CP_NG_RSA_METHOD_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpp192r1precomca.c b/ext/ipp/sources/ippcp/pcpp192r1precomca.c
index da89e32..7bb2c44 100644
--- a/ext/ipp/sources/ippcp/src/pcpp192r1precomca.c
+++ b/ext/ipp/sources/ippcp/pcpp192r1precomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/src/pcpp224r1precomca.c b/ext/ipp/sources/ippcp/pcpp224r1precomca.c
index 8232f38..9b4a1ce 100644
--- a/ext/ipp/sources/ippcp/src/pcpp224r1precomca.c
+++ b/ext/ipp/sources/ippcp/pcpp224r1precomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/src/pcpp256r1precomca.c b/ext/ipp/sources/ippcp/pcpp256r1precomca.c
index b5af776..0d16ffa 100644
--- a/ext/ipp/sources/ippcp/src/pcpp256r1precomca.c
+++ b/ext/ipp/sources/ippcp/pcpp256r1precomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/src/pcpp384r1precomca.c b/ext/ipp/sources/ippcp/pcpp384r1precomca.c
index 9e87cb3..be3f73a 100644
--- a/ext/ipp/sources/ippcp/src/pcpp384r1precomca.c
+++ b/ext/ipp/sources/ippcp/pcpp384r1precomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/src/pcpp521r1precomca.c b/ext/ipp/sources/ippcp/pcpp521r1precomca.c
index 30d9982..ca772d2 100644
--- a/ext/ipp/sources/ippcp/src/pcpp521r1precomca.c
+++ b/ext/ipp/sources/ippcp/pcpp521r1precomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/pcpprime_isco.h b/ext/ipp/sources/ippcp/pcpprime_isco.h
new file mode 100644
index 0000000..1e86a86
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprime_isco.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprimeg.h"
+#include "pcpprng.h"
+#include "pcpngrsa.h"
+
+/* test if E and A are coprime */
+static int cpIsCoPrime(BNU_CHUNK_T* pA, int nsA,
+ BNU_CHUNK_T* pB, int nsB,
+ BNU_CHUNK_T* pBuffer)
+{
+ if (nsA>nsB) {
+ SWAP_PTR(BNU_CHUNK_T, pA, pB);
+ SWAP(nsA, nsB);
+ }
+ {
+ IppsBigNumState bnA, bnB, bnGcd;
+ BNU_CHUNK_T* pDataA = pBuffer;
+ BNU_CHUNK_T* pBuffA = pDataA + nsA + 1;
+ BNU_CHUNK_T* pDataB = pBuffA + nsA + 1;
+ BNU_CHUNK_T* pBuffB = pDataB + nsB + 1;
+ BNU_CHUNK_T* pDataGcd = pBuffB + nsB + 1;
+ BNU_CHUNK_T* pBuffGcd = pDataGcd + nsB + 1;
+
+ BN_Make(pDataA, pBuffA, nsA, &bnA);
+ BN_Make(pDataB, pBuffB, nsB, &bnB);
+ BN_Make(pDataGcd, pBuffGcd, nsB, &bnGcd);
+
+ COPY_BNU(pDataA, pA, nsA)
+ BN_Set(pDataA, nsA, &bnA);
+ COPY_BNU(pDataB, pB, nsB)
+ BN_Set(pDataB, nsB, &bnB);
+ ippsGcd_BN(&bnA, &bnB, &bnGcd);
+ return 0 == cpBN_cmp(&bnGcd, cpBN_OneRef());
+ }
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpprime_isprob.h b/ext/ipp/sources/ippcp/pcpprime_isprob.h
new file mode 100644
index 0000000..bc684d6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprime_isprob.h
@@ -0,0 +1,143 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprimeg.h"
+#include "pcpprng.h"
+#include "pcpngrsa.h"
+
+
+static int cpMillerRabinTest(BNU_CHUNK_T* pW, cpSize nsW,
+ const BNU_CHUNK_T* pE, cpSize bitsizeE,
+ int k,
+ const BNU_CHUNK_T* pPrime1,
+ gsModEngine* pMont,
+ BNU_CHUNK_T* pBuffer)
+{
+ cpSize nsP = MOD_LEN(pMont);
+
+ /* to Montgomery Domain */
+ ZEXPAND_BNU(pW, nsW, nsP);
+ MOD_METHOD(pMont)->encode(pW, pW, pMont);
+
+ /* w = exp(w,e) */
+ gsMontExpWin_BNU_sscm(pW, pW, nsP, pE, bitsizeE, pMont, pBuffer);
+
+ /* if (w==1) ||(w==prime-1) => probably prime */
+ if ((0 == cpCmp_BNU(pW, nsP, MOD_MNT_R(pMont), nsP))
+ || (0 == cpCmp_BNU(pW, nsP, pPrime1, nsP)))
+ return 1; /* witness of the primality */
+
+ while (--k) {
+ MOD_METHOD(pMont)->sqr(pW, pW, pMont);
+
+ if (0 == cpCmp_BNU(pW, nsP, MOD_MNT_R(pMont), nsP))
+ return 0; /* witness of the compositeness */
+ if (0 == cpCmp_BNU(pW, nsP, pPrime1, nsP))
+ return 1; /* witness of the primality */
+ }
+ return 0;
+}
+
+/* test if P is prime
+
+returns:
+IPP_IS_PRIME (==1) - prime value has been detected
+IPP_IS_COMPOSITE (==0) - composite value has been detected
+-1 - if internal error (ippStsNoErr != rndFunc())
+*/
+static int cpIsProbablyPrime(BNU_CHUNK_T* pPrime, int bitSize,
+ int nTrials,
+ IppBitSupplier rndFunc, void* pRndParam,
+ gsModEngine* pME,
+ BNU_CHUNK_T* pBuffer)
+{
+ /* if test for trivial divisors passed*/
+ int ret = cpMimimalPrimeTest((Ipp32u*)pPrime, BITS2WORD32_SIZE(bitSize));
+
+ /* appy Miller-Rabin test */
+ if (ret) {
+ int ns = BITS_BNU_CHUNK(bitSize);
+ BNU_CHUNK_T* pPrime1 = pBuffer;
+ BNU_CHUNK_T* pOdd = pPrime1 + ns;
+ BNU_CHUNK_T* pWitness = pOdd + ns;
+ BNU_CHUNK_T* pMontPrime1 = pWitness + ns;
+ BNU_CHUNK_T* pScratchBuffer = pMontPrime1 + ns;
+ int k, a, lenOdd;
+
+ /* prime1 = prime-1 = odd*2^a */
+ cpDec_BNU(pPrime1, pPrime, ns, 1);
+ for (k = 0, a = 0; k<ns; k++) {
+ cpSize da = cpNTZ_BNU(pPrime1[k]);
+ a += da;
+ if (BNU_CHUNK_BITS != da)
+ break;
+ }
+ lenOdd = cpLSR_BNU(pOdd, pPrime1, ns, a);
+ FIX_BNU(pOdd, lenOdd);
+
+ /* prime1 to (Montgomery Domain) */
+ cpSub_BNU(pMontPrime1, pPrime, MOD_MNT_R(pME), ns);
+
+ for (k = 0, ret = 0; k<nTrials && !ret; k++) {
+ BNU_CHUNK_T one = 1;
+ ret = cpPRNGenRange(pWitness, &one, 1, pPrime1, ns, rndFunc, pRndParam);
+ if (ret <= 0) break; /* internal error */
+ /* test primality */
+ ret = cpMillerRabinTest(pWitness, ns,
+ //pOdd, lenOdd, a,
+ pOdd, bitSize - a, a,
+ pMontPrime1,
+ pME, pScratchBuffer);
+ }
+ }
+ return ret;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpprimeg.h b/ext/ipp/sources/ippcp/pcpprimeg.h
new file mode 100644
index 0000000..78bfe40
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprimeg.h
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+// Prime Number Primitives.
+//
+//
+*/
+
+
+#if !defined(_CP_PRIME_H)
+#define _CP_PRIME_H
+
+#include "pcpbn.h"
+#include "pcpmontgomery.h"
+
+
+/*
+// Prime context
+*/
+struct _cpPrime {
+ IppCtxId idCtx; /* Prime context identifier */
+ cpSize maxBitSize; /* max bit length */
+ BNU_CHUNK_T* pPrime; /* prime value */
+ BNU_CHUNK_T* pT1; /* temporary BNU */
+ BNU_CHUNK_T* pT2; /* temporary BNU */
+ BNU_CHUNK_T* pT3; /* temporary BNU */
+ gsModEngine* pMont; /* montgomery engine */
+};
+
+/* alignment */
+#define PRIME_ALIGNMENT ((int)sizeof(void*))
+
+/* Prime accessory macros */
+#define PRIME_ID(ctx) ((ctx)->idCtx)
+#define PRIME_MAXBITSIZE(ctx) ((ctx)->maxBitSize)
+#define PRIME_NUMBER(ctx) ((ctx)->pPrime)
+#define PRIME_TEMP1(ctx) ((ctx)->pT1)
+#define PRIME_TEMP2(ctx) ((ctx)->pT2)
+#define PRIME_TEMP3(ctx) ((ctx)->pT3)
+#define PRIME_MONT(ctx) ((ctx)->pMont)
+
+#define PRIME_VALID_ID(ctx) (PRIME_ID((ctx))==idCtxPrimeNumber)
+
+/*
+// Number of Miller-Rabin rounds for an error rate of less than 1/2^80 for random 'b'-bit input, b >= 100.
+// (see Table 4.4, Handbook of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]
+*/
+#define MR_rounds_p80(b) ((b) >= 1300 ? 2 : \
+ (b) >= 850 ? 3 : \
+ (b) >= 650 ? 4 : \
+ (b) >= 550 ? 5 : \
+ (b) >= 450 ? 6 : \
+ (b) >= 400 ? 7 : \
+ (b) >= 350 ? 8 : \
+ (b) >= 300 ? 9 : \
+ (b) >= 250 ? 12 : \
+ (b) >= 200 ? 15 : \
+ (b) >= 150 ? 18 : \
+ /*(b) >= 100*/ 27)
+
+/* easy prime test */
+#define cpMimimalPrimeTest OWNAPI(cpMimimalPrimeTest)
+int cpMimimalPrimeTest(const Ipp32u* pPrime, cpSize ns);
+
+/* prime test */
+#define cpPrimeTest OWNAPI(cpPrimeTest)
+int cpPrimeTest(const BNU_CHUNK_T* pPrime, cpSize primeLen,
+ cpSize nTrials,
+ IppsPrimeState* pCtx,
+ IppBitSupplier rndFunc, void* pRndParam);
+
+#define cpPackPrimeCtx OWNAPI(cpPackPrimeCtx)
+void cpPackPrimeCtx(const IppsPrimeState* pCtx, Ipp8u* pBuffer);
+#define cpUnpackPrimeCtx OWNAPI(cpUnpackPrimeCtx)
+void cpUnpackPrimeCtx(const Ipp8u* pBuffer, IppsPrimeState* pCtx);
+
+#endif /* _CP_PRIME_H */
diff --git a/ext/ipp/sources/ippcp/pcpprng.h b/ext/ipp/sources/ippcp/pcpprng.h
new file mode 100644
index 0000000..af1ae5f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprng.h
@@ -0,0 +1,95 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal Pseudo Random Generator Function Prototypes
+//
+*/
+
+#if !defined(_CP_PRNG_H)
+#define _CP_PRNG_H
+
+/*
+// Pseudo-random generation context
+*/
+
+#define MAX_XKEY_SIZE 512
+#define DEFAULT_XKEY_SIZE 512 /* must be >=160 || <=512 */
+
+struct _cpPRNG {
+ IppCtxId idCtx; /* PRNG identifier */
+ cpSize seedBits; /* secret seed-key bitsize */
+ BNU_CHUNK_T Q[BITS_BNU_CHUNK(160)]; /* modulus */
+ BNU_CHUNK_T T[BITS_BNU_CHUNK(160)]; /* parameter of SHA_G() funct */
+ BNU_CHUNK_T xAug[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* optional entropy augment */
+ BNU_CHUNK_T xKey[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* secret seed-key */
+};
+
+/* alignment */
+#define PRNG_ALIGNMENT ((int)(sizeof(void*)))
+
+#define RAND_ID(ctx) ((ctx)->idCtx)
+#define RAND_SEEDBITS(ctx) ((ctx)->seedBits)
+#define RAND_Q(ctx) ((ctx)->Q)
+#define RAND_T(ctx) ((ctx)->T)
+#define RAND_XAUGMENT(ctx) ((ctx)->xAug)
+#define RAND_XKEY(ctx) ((ctx)->xKey)
+
+#define RAND_VALID_ID(ctx) (RAND_ID((ctx))==idCtxPRNG)
+
+#define cpPRNGen OWNAPI(cpPRNGen)
+int cpPRNGen(Ipp32u* pBuffer, cpSize bitLen, IppsPRNGState* pCtx);
+
+#define cpPRNGenPattern OWNAPI(cpPRNGenPattern)
+int cpPRNGenPattern(BNU_CHUNK_T* pRand, int bitSize,
+ BNU_CHUNK_T botPattern, BNU_CHUNK_T topPattern,
+ IppBitSupplier rndFunc, void* pRndParam);
+
+#define cpPRNGenRange OWNAPI(cpPRNGenRange)
+int cpPRNGenRange(BNU_CHUNK_T* pRand,
+ const BNU_CHUNK_T* pLo, cpSize loLen,
+ const BNU_CHUNK_T* pHi, cpSize hiLen,
+ IppBitSupplier rndFunc, void* pRndParam);
+
+#endif /* _CP_PRNG_H */
diff --git a/ext/ipp/sources/ippcp/pcpprng_gen.c b/ext/ipp/sources/ippcp/pcpprng_gen.c
new file mode 100644
index 0000000..4329b6d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprng_gen.c
@@ -0,0 +1,171 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// cpPRNGen()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcphash.h"
+#include "pcpprng.h"
+#include "pcptool.h"
+
+
+/*
+// G() function based on SHA1
+//
+// Parameters:
+// T 160 bit parameter
+// pHexStr input hex string
+// hexStrLen size of hex string (Ipp8u segnments)
+// xBNU 160 bit BNU result
+//
+// Note 1:
+// must to be hexStrLen <= 64 (512 bits)
+*/
+static
+void SHA1_G(Ipp32u* xBNU, const Ipp32u* T, Ipp8u* pHexStr, int hexStrLen)
+{
+ /* select processing function */
+ cpHashProc updateFunc;
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ updateFunc = UpdateSHA1ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA1ni : UpdateSHA1;
+ #else
+ updateFunc = UpdateSHA1;
+ #endif
+
+ /* pad HexString zeros */
+ PaddBlock(0, pHexStr+hexStrLen, BITS2WORD8_SIZE(MAX_XKEY_SIZE)-hexStrLen);
+
+ /* reset initial HASH value */
+ xBNU[0] = T[0];
+ xBNU[1] = T[1];
+ xBNU[2] = T[2];
+ xBNU[3] = T[3];
+ xBNU[4] = T[4];
+
+ /* SHA1 */
+ //UpdateSHA1(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
+ updateFunc(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
+
+ /* swap back */
+ SWAP(xBNU[0],xBNU[4]);
+ SWAP(xBNU[1],xBNU[3]);
+}
+
+/*F*
+// Name: cpPRNGen
+//
+// Purpose: Returns bitsize of the bitstring has beed added
+//
+// Returns:
+// bitsize of the bitstring has beed added
+//
+// Parameters:
+// pRand pointer to the buffer
+// nBits number of bits be requested
+// pRnd pointer to the context
+*F*/
+
+int cpPRNGen(Ipp32u* pRand, cpSize nBits, IppsPRNGState* pRnd)
+{
+ BNU_CHUNK_T Xj [BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
+ BNU_CHUNK_T XVAL[BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
+
+ Ipp8u TXVAL[BITS2WORD8_SIZE(MAX_XKEY_SIZE)];
+
+ /* XKEY length in BNU_CHUNK_T */
+ cpSize xKeyLen = BITS_BNU_CHUNK(RAND_SEEDBITS(pRnd));
+ /* XKEY length in bytes */
+ cpSize xKeySize= BITS2WORD8_SIZE(RAND_SEEDBITS(pRnd));
+ /* XKEY word's mask */
+ BNU_CHUNK_T xKeyMsk = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd));
+
+ /* number of Ipp32u chunks to be generated */
+ cpSize genlen = BITS2WORD32_SIZE(nBits);
+
+ ZEXPAND_BNU(Xj, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
+ ZEXPAND_BNU(XVAL, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
+
+ while(genlen) {
+ cpSize len;
+
+ /* Step 1: XVAL=(Xkey+Xseed) mod 2^b */
+ BNU_CHUNK_T carry = cpAdd_BNU(XVAL, RAND_XKEY(pRnd), RAND_XAUGMENT(pRnd), xKeyLen);
+ XVAL[xKeyLen-1] &= xKeyMsk;
+
+ /* Step 2: xj=G(t, XVAL) mod Q */
+ cpToOctStr_BNU(TXVAL, xKeySize, XVAL, xKeyLen);
+ SHA1_G((Ipp32u*)Xj, (Ipp32u*)RAND_T(pRnd), TXVAL, xKeySize);
+
+ {
+ cpSize sizeXj = BITS_BNU_CHUNK(160);
+ if(0 <= cpCmp_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd),BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE)) )
+ sizeXj = cpMod_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd), BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE));
+ FIX_BNU(Xj, sizeXj);
+ ZEXPAND_BNU(Xj, sizeXj, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
+ }
+
+ /* Step 3: Xkey=(1+Xkey+Xj) mod 2^b */
+ cpInc_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), xKeyLen, 1);
+ carry = cpAdd_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), Xj, xKeyLen);
+ RAND_XKEY(pRnd)[xKeyLen-1] &= xKeyMsk;
+
+ /* fill out result */
+ len = genlen<BITS2WORD32_SIZE(IPP_SHA1_DIGEST_BITSIZE)? genlen : BITS2WORD32_SIZE(IPP_SHA1_DIGEST_BITSIZE);
+ COPY_BNU(pRand, (Ipp32u*)Xj, len);
+
+ pRand += len;
+ genlen -= len;
+ }
+
+ return nBits;
+}
diff --git a/ext/ipp/sources/ippcp/pcpprng_genhw.h b/ext/ipp/sources/ippcp/pcpprng_genhw.h
new file mode 100644
index 0000000..4216d75
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprng_genhw.h
@@ -0,0 +1,130 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// HW random generator
+//
+//
+*/
+
+#include "owndefs.h"
+
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+#if !defined (_PCP_PRN_GEN_HW_H)
+#define _PCP_PRN_GEN_HW_H
+
+#if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+__INLINE int cpRand_hw_sample(BNU_CHUNK_T* pSample)
+{
+#define LOCAL_COUNTER (8)
+ int n;
+ int success = 0;
+ for(n=0; n<LOCAL_COUNTER && !success; n++)
+ #if (_IPP_ARCH == _IPP_ARCH_IA32)
+ success = _rdrand32_step(pSample);
+ #elif (_IPP_ARCH == _IPP_ARCH_EM64T)
+ success = _rdrand64_step(pSample);
+ #else
+ #error Unknown CPU arch
+ #endif
+ return success;
+#undef LOCAL_COUNTER
+}
+
+#if (_IPP32E>=_IPP32E_E9)
+__INLINE int cpRand_hw_sample32(Ipp32u* pSample)
+{
+#define LOCAL_COUNTER (8)
+ int n;
+ int success = 0;
+ for(n=0; n<LOCAL_COUNTER && !success; n++)
+ success = _rdrand32_step(pSample);
+ return success;
+#undef LOCAL_COUNTER
+}
+#endif
+
+/*F*
+// Name: cpRandHW_buffer
+//
+// Purpose: Generates a pseudorandom bit sequence
+// based on RDRAND instruction of the specified nBits length.
+//
+// Returns: Reason:
+// 1 no errors
+// 0 random bit sequence can't be generated
+//
+// Parameters:
+// pBuffer pointer to the buffer
+// bufLen buffer length
+*F*/
+
+__INLINE int cpRandHW_buffer(Ipp32u* pBuffer, int bufLen)
+{
+ int nSamples = bufLen/(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+
+ int n;
+ /* collect nSamples randoms */
+ for(n=0; n<nSamples; n++, pBuffer+=(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
+ if( !cpRand_hw_sample((BNU_CHUNK_T*)pBuffer))
+ return 0;
+ }
+
+ #if (_IPP32E>=_IPP32E_E9)
+ if( bufLen%(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)) ) {
+ if( !cpRand_hw_sample32(pBuffer)) {
+ return 0;
+ }
+ }
+ #endif
+ return 1;
+}
+#endif
+
+#endif /* #if !defined (_PCP_PRN_GEN_HW_H) */
diff --git a/ext/ipp/sources/ippcp/pcpprngen_bn.c b/ext/ipp/sources/ippcp/pcpprngen_bn.c
new file mode 100644
index 0000000..3ec6f13
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngen_bn.c
@@ -0,0 +1,114 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGen_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcphash.h"
+#include "pcpprng.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsPRNGen_BN
+//
+// Purpose: Generates a pseudorandom big number of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pRand
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pRand->idCtx
+//
+// ippStsLengthErr 1 > nBits
+// nBits > BN_ROOM(pRand)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the BN random
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGen_BN,(IppsBigNumState* pRand, int nBits, void* pCtx))
+{
+ IppsPRNGState* pRndCtx;
+
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr);
+
+ /* test random BN */
+ IPP_BAD_PTR1_RET(pRand);
+ pRand = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRand, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pRand), ippStsContextMatchErr);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+ IPP_BADARG_RET(nBits> BN_ROOM(pRand)*BNU_CHUNK_BITS, ippStsLengthErr);
+
+
+ {
+ BNU_CHUNK_T* pRandBN = BN_NUMBER(pRand);
+ cpSize rndSize = BITS_BNU_CHUNK(nBits);
+ BNU_CHUNK_T rndMask = MASK_BNU_CHUNK(nBits);
+
+ cpPRNGen((Ipp32u*)pRandBN, nBits, pRndCtx);
+ pRandBN[rndSize-1] &= rndMask;
+
+ FIX_BNU(pRandBN, rndSize);
+ BN_SIZE(pRand) = rndSize;
+ BN_SIGN(pRand) = ippBigNumPOS;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngen_pattern.c b/ext/ipp/sources/ippcp/pcpprngen_pattern.c
new file mode 100644
index 0000000..f2cd0f3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngen_pattern.c
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// cpPRNGenPattern()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcphash.h"
+#include "pcpprng.h"
+#include "pcptool.h"
+
+/* generates random string of specified bitSize length
+ returns:
+ 1 random bit string generated
+ -1 detected internal error (ippStsNoErr != rndFunc())
+*/
+int cpPRNGenPattern(BNU_CHUNK_T* pRand, int bitSize,
+ BNU_CHUNK_T botPattern, BNU_CHUNK_T topPattern,
+ IppBitSupplier rndFunc, void* pRndParam)
+{
+ BNU_CHUNK_T topMask = MASK_BNU_CHUNK(bitSize);
+ cpSize randLen = BITS_BNU_CHUNK(bitSize);
+
+ IppStatus sts = rndFunc((Ipp32u*)pRand, bitSize, pRndParam);
+ if(ippStsNoErr!=sts) return -1;
+
+ pRand[randLen-1] &= topMask;
+ pRand[0] |= botPattern;
+ pRand[randLen-1] |= topPattern;
+ return 1;
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngen_range.c b/ext/ipp/sources/ippcp/pcpprngen_range.c
new file mode 100644
index 0000000..dfbed46
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngen_range.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// cpPRNGenRange()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcphash.h"
+#include "pcpprng.h"
+#include "pcptool.h"
+
+/* generates random string of specified bitSize length
+ within specified ragnge lo < r < Hi
+ returns:
+ 0 random bit string not generated
+ 1 random bit string generated
+ -1 detected internal error (ippStsNoErr != rndFunc())
+*/
+int cpPRNGenRange(BNU_CHUNK_T* pRand,
+ const BNU_CHUNK_T* pLo, cpSize loLen,
+ const BNU_CHUNK_T* pHi, cpSize hiLen,
+ IppBitSupplier rndFunc, void* pRndParam)
+{
+ int bitSize = BITSIZE_BNU(pHi,hiLen);
+ BNU_CHUNK_T topMask = MASK_BNU_CHUNK(bitSize);
+
+ #define MAX_COUNT (1000)
+ int n;
+ for(n=0; n<MAX_COUNT; n++) {
+ cpSize randLen;
+ IppStatus sts = rndFunc((Ipp32u*)pRand, bitSize, pRndParam);
+ if(ippStsNoErr!=sts) return -1;
+
+ pRand[hiLen-1] &= topMask;
+ randLen = cpFix_BNU(pRand, hiLen);
+ if((0 < cpCmp_BNU(pRand, randLen, pLo, loLen)) && (0 < cpCmp_BNU(pHi, hiLen, pRand, randLen)))
+ return 1;
+ }
+ #undef MAX_COUNT
+
+ return 0; /* no random matched to (Lo,Hi) */
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngenca.c b/ext/ipp/sources/ippcp/pcpprngenca.c
new file mode 100644
index 0000000..3a962ea
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngenca.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGen()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcphash.h"
+#include "pcpprng.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsPRNGen
+//
+// Purpose: Generates a pseudorandom bit sequence of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pRand
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+//
+// ippStsLengthErr 1 > nBits
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the buffer
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+
+IPPFUN(IppStatus, ippsPRNGen,(Ipp32u* pRand, int nBits, void* pCtx))
+{
+ IppsPRNGState* pCtxCtx = (IppsPRNGState*)pCtx;
+
+ /* test PRNG context */
+ IPP_BAD_PTR2_RET(pRand, pCtx);
+
+ pCtxCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtxCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtxCtx), ippStsContextMatchErr);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+
+ {
+ cpSize rndSize = BITS2WORD32_SIZE(nBits);
+ Ipp32u rndMask = MAKEMASK32(nBits);
+
+ cpPRNGen(pRand, nBits, pCtxCtx);
+ pRand[rndSize-1] &= rndMask;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngenhw_bn.c b/ext/ipp/sources/ippcp/pcpprngenhw_bn.c
new file mode 100644
index 0000000..30a5994
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngenhw_bn.c
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGenRDRAND_BN()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+#include "pcpprng_genhw.h"
+
+/*F*
+// Name: ippsPRNGenRDRAND_BN
+//
+// Purpose: Generates a pseudorandom big number
+// based on RDRAND instruction of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pBuffer
+//
+// ippStsLengthErr 1 > nBits
+// nBits > BN_ROOM(pRand)
+//
+// ippStsNotSupportedModeErr unsupported rdrand instruction
+//
+// ippStsErr random big number can't be generated
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the big number
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGenRDRAND_BN,(IppsBigNumState* pRand, int nBits, void* pCtx))
+{
+ /* test random BN */
+ IPP_BAD_PTR1_RET(pRand);
+ pRand = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRand, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pRand), ippStsContextMatchErr);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+ IPP_BADARG_RET(nBits> BN_ROOM(pRand)*BNU_CHUNK_BITS, ippStsLengthErr);
+
+ UNREFERENCED_PARAMETER(pCtx);
+
+ #if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+ if( IsFeatureEnabled(ippCPUID_RDRAND) ) {
+ BNU_CHUNK_T* pRandBN = BN_NUMBER(pRand);
+ cpSize rndSize = BITS_BNU_CHUNK(nBits);
+ BNU_CHUNK_T rndMask = MASK_BNU_CHUNK(nBits);
+
+ if(cpRandHW_buffer((Ipp32u*)pRandBN, rndSize*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
+ pRandBN[rndSize-1] &= rndMask;
+
+ FIX_BNU(pRandBN, rndSize);
+ BN_SIZE(pRand) = rndSize;
+ BN_SIGN(pRand) = ippBigNumPOS;
+
+ return ippStsNoErr;
+ }
+ else
+ return ippStsErr;
+ }
+
+ /* unsupported rdrand instruction */
+ else
+ #endif
+ IPP_ERROR_RET(ippStsNotSupportedModeErr);
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngenhwca.c b/ext/ipp/sources/ippcp/pcpprngenhwca.c
new file mode 100644
index 0000000..5e6e484
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngenhwca.c
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGenRDRAND()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+#include "pcpprng_genhw.h"
+
+/*F*
+// Name: ippsPRNGenRDRAND
+//
+// Purpose: Generates a pseudorandom bit sequence
+// based on RDRAND instruction of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pRand
+//
+// ippStsLengthErr 1 > nBits
+//
+// ippStsNotSupportedModeErr unsupported rdrand instruction
+//
+// ippStsErr random bit sequence can't be generated
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the buffer
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGenRDRAND,(Ipp32u* pRand, int nBits, void* pCtx))
+{
+ /* test PRNG buffer */
+ IPP_BAD_PTR1_RET(pRand);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+
+ UNREFERENCED_PARAMETER(pCtx);
+
+ #if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+ if( IsFeatureEnabled(ippCPUID_RDRAND) ) {
+ cpSize rndSize = BITS2WORD32_SIZE(nBits);
+ Ipp32u rndMask = MAKEMASK32(nBits);
+
+ if(cpRandHW_buffer(pRand, rndSize)) {
+ pRand[rndSize-1] &= rndMask;
+ return ippStsNoErr;
+ }
+ else
+ return ippStsErr;
+ }
+ /* unsupported rdrand instruction */
+ else
+ #endif
+ IPP_ERROR_RET(ippStsNotSupportedModeErr);
+}
diff --git a/ext/ipp/sources/ippcp/pcpprnggetseed.c b/ext/ipp/sources/ippcp/pcpprnggetseed.c
new file mode 100644
index 0000000..7aa6f5f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprnggetseed.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGGetSeed()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+
+/*F*
+// Name: ippsPRNGGetSeed
+//
+// Purpose: Get current SEED value from the state
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pSeed
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pSeed->idCtx
+// ippStsOutOfRangeErr length of the actual SEED > length SEED destination
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pCtx pointer to the context
+// pSeed pointer to the SEED
+*F*/
+IPPFUN(IppStatus, ippsPRNGGetSeed, (const IppsPRNGState* pCtx, IppsBigNumState* pSeed))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ /* test seed */
+ IPP_BAD_PTR1_RET(pSeed);
+ pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr);
+
+ return ippsSet_BN(ippBigNumPOS,
+ BITS2WORD32_SIZE(RAND_SEEDBITS(pCtx)),
+ (Ipp32u*)RAND_XKEY(pCtx),
+ pSeed);
+}
diff --git a/ext/ipp/sources/ippcp/pcpprnggetsize.c b/ext/ipp/sources/ippcp/pcpprnggetsize.c
new file mode 100644
index 0000000..044bd57
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprnggetsize.c
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGGetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsPRNGGetSize
+//
+// Purpose: Returns size of PRNG context (bytes).
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pSize
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pSize pointer to the size of internal context
+*F*/
+IPPFUN(IppStatus, ippsPRNGGetSize, (int* pSize))
+{
+ IPP_BAD_PTR1_RET(pSize);
+
+ *pSize = sizeof(IppsPRNGState)
+ +PRNG_ALIGNMENT-1;
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpprnginitca.c b/ext/ipp/sources/ippcp/pcpprnginitca.c
new file mode 100644
index 0000000..b38e3bb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprnginitca.c
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGInit()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsPRNGInit
+//
+// Purpose: Initializes PRNG context
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+//
+// ippStsLengthErr seedBits < 1
+// seedBits < MAX_XKEY_SIZE
+// seedBits % 8 !=0
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// seedBits seed bitsize
+// pCtx pointer to the context to be initialized
+*F*/
+IPPFUN(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pCtx))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+
+ /* test sizes */
+ IPP_BADARG_RET((1>seedBits) || (seedBits>MAX_XKEY_SIZE) ||(seedBits&7), ippStsLengthErr);
+
+ {
+ int hashIvSize = cpHashIvSize(ippHashAlg_SHA1);
+ const Ipp8u* iv = cpHashIV[ippHashAlg_SHA1];
+
+ /* cleanup context */
+ ZEXPAND_BNU((Ipp8u*)pCtx, 0, (cpSize)(sizeof(IppsPRNGState)));
+
+ RAND_ID(pCtx) = idCtxPRNG;
+ RAND_SEEDBITS(pCtx) = seedBits;
+
+ /* default Q parameter */
+ ((Ipp32u*)RAND_Q(pCtx))[0] = 0xFFFFFFFF;
+ ((Ipp32u*)RAND_Q(pCtx))[1] = 0xFFFFFFFF;
+ ((Ipp32u*)RAND_Q(pCtx))[2] = 0xFFFFFFFF;
+ ((Ipp32u*)RAND_Q(pCtx))[3] = 0xFFFFFFFF;
+ ((Ipp32u*)RAND_Q(pCtx))[4] = 0xFFFFFFFF;
+
+ /* default T parameter */
+ CopyBlock(iv, RAND_T(pCtx), hashIvSize);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngsetaugment.c b/ext/ipp/sources/ippcp/pcpprngsetaugment.c
new file mode 100644
index 0000000..fa11611
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngsetaugment.c
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGSetAugment()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+
+/*F*
+// Name: ippsPRNGSetAugment
+//
+// Purpose: Sets the Entropy Augmentation
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pAug
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pAug->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pAug pointer to the entropy eugmentation
+// pCtx pointer to the context
+*F*/
+
+IPPFUN(IppStatus, ippsPRNGSetAugment, (const IppsBigNumState* pAug, IppsPRNGState* pCtx))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ /* test augmentation */
+ IPP_BAD_PTR1_RET(pAug);
+ pAug = (IppsBigNumState*)( IPP_ALIGNED_PTR(pAug, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pAug), ippStsContextMatchErr);
+
+ {
+ cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pCtx) );
+ BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pCtx));
+ cpSize size = IPP_MIN(BN_SIZE(pAug), argSize);
+
+ ZEXPAND_COPY_BNU(RAND_XAUGMENT(pCtx), (cpSize)(sizeof(RAND_XAUGMENT(pCtx))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pAug), size);
+ RAND_XAUGMENT(pCtx)[argSize-1] &= mask;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngsetca.c b/ext/ipp/sources/ippcp/pcpprngsetca.c
new file mode 100644
index 0000000..33da9d6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngsetca.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGSetH0()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+
+/*F*
+// Name: ippsPRNGSetH0
+//
+// Purpose: Sets 160-bit parameter of G() function.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pH0
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pH0->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pH0 pointer to the parameter used into G() function
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGSetH0,(const IppsBigNumState* pH0, IppsPRNGState* pCtx))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ /* test H0 */
+ IPP_BAD_PTR1_RET(pH0);
+ pH0 = (IppsBigNumState*)( IPP_ALIGNED_PTR(pH0, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pH0), ippStsContextMatchErr);
+
+ {
+ cpSize len = IPP_MIN(5, BN_SIZE(pH0)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)));
+ ZEXPAND_BNU(RAND_T(pCtx), 0, (int)(sizeof(RAND_T(pCtx))/sizeof(BNU_CHUNK_T)));
+ ZEXPAND_COPY_BNU((Ipp32u*)RAND_T(pCtx), (int)(sizeof(RAND_T(pCtx))/sizeof(Ipp32u)),
+ (Ipp32u*)BN_NUMBER(pH0), len);
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngsetmodulus.c b/ext/ipp/sources/ippcp/pcpprngsetmodulus.c
new file mode 100644
index 0000000..274ad49
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngsetmodulus.c
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGSetModulus()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+
+/*F*
+// Name: ippsPRNGSetModulus
+//
+// Purpose: Sets 160-bit modulus Q.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pMod
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pMod->idCtx
+//
+// ippStsBadArgErr 160 != bitsize(pMod)
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pMod pointer to the 160-bit modulus
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGSetModulus, (const IppsBigNumState* pMod, IppsPRNGState* pCtx))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ /* test modulus */
+ IPP_BAD_PTR1_RET(pMod);
+ pMod = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMod, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pMod), ippStsContextMatchErr);
+ IPP_BADARG_RET(160 != BITSIZE_BNU(BN_NUMBER(pMod),BN_SIZE(pMod)), ippStsBadArgErr);
+
+ ZEXPAND_COPY_BNU(RAND_Q(pCtx), (int)(sizeof(RAND_Q(pCtx))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pMod), BN_SIZE(pMod));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpprngsetseed.c b/ext/ipp/sources/ippcp/pcpprngsetseed.c
new file mode 100644
index 0000000..bc3e529
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpprngsetseed.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2004-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// PRNG Functions
+//
+// Contents:
+// ippsPRNGSetSeed()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpprng.h"
+
+/*F*
+// Name: ippsPRNGSetSeed
+//
+// Purpose: Sets the initial state with the SEED value
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pCtx
+// NULL == pSeed
+//
+// ippStsContextMatchErr illegal pCtx->idCtx
+// illegal pSeed->idCtx
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pSeed pointer to the SEED
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsPRNGSetSeed, (const IppsBigNumState* pSeed, IppsPRNGState* pCtx))
+{
+ /* test PRNG context */
+ IPP_BAD_PTR1_RET(pCtx);
+ pCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pCtx, PRNG_ALIGNMENT) );
+ IPP_BADARG_RET(!RAND_VALID_ID(pCtx), ippStsContextMatchErr);
+
+ /* test seed */
+ IPP_BAD_PTR1_RET(pSeed);
+ pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr);
+
+ {
+ cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pCtx) );
+ BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pCtx));
+ cpSize size = IPP_MIN(BN_SIZE(pSeed), argSize);
+
+ ZEXPAND_COPY_BNU(RAND_XKEY(pCtx), (cpSize)(sizeof(RAND_XKEY(pCtx))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pSeed), size);
+ RAND_XKEY(pCtx)[argSize-1] &= mask;
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcprij.h b/ext/ipp/sources/ippcp/pcprij.h
new file mode 100644
index 0000000..fe0f20c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprij.h
@@ -0,0 +1,255 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal Rijndael based Encrypt/Decrypt Function Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_RIJ_H)
+#define _PCP_RIJ_H
+
+
+/*
+// The GF(256) modular polynomial and elements
+*/
+#define WPOLY 0x011B
+#define BPOLY 0x1B
+
+/*
+// Make WORD using 4 arbitrary bytes
+*/
+#define BYTES_TO_WORD(b0,b1,b2,b3) ( ( ((Ipp32u)((Ipp8u)(b3))) <<24 ) \
+ |( ((Ipp32u)((Ipp8u)(b2))) <<16 ) \
+ |( ((Ipp32u)((Ipp8u)(b1))) << 8 ) \
+ |( ((Ipp32u)((Ipp8u)(b0))) ) )
+/*
+// Make WORD setting byte in specified position
+*/
+#define BYTE0_TO_WORD(b) BYTES_TO_WORD((b), 0, 0, 0)
+#define BYTE1_TO_WORD(b) BYTES_TO_WORD( 0, (b), 0, 0)
+#define BYTE2_TO_WORD(b) BYTES_TO_WORD( 0, 0, (b), 0)
+#define BYTE3_TO_WORD(b) BYTES_TO_WORD( 0, 0, 0, (b))
+
+/*
+// Extract byte from specified position n.
+// Sure, n=0,1,2 or 3 only
+*/
+#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n))))
+
+
+/*
+// Rijndael's spec
+//
+// Rijndael128, Rijndael192 and Rijndael256
+// reserve space for maximum number of expanded keys
+*/
+typedef void (*RijnCipher)(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+
+struct _cpRijndael128 {
+ IppCtxId idCtx; /* Rijndael spec identifier */
+ int nk; /* security key length (words) */
+ int nb; /* data block size (words) */
+ int nr; /* number of rounds */
+ RijnCipher encoder; /* encoder/decoder */
+ RijnCipher decoder; /* entry point */
+ Ipp32u* pEncTbl; /* expanded S-boxes for */
+ Ipp32u* pDecTbl; /* encryption and decryption */
+ Ipp32u enc_keys[64]; /* array of keys for encryprion */
+ Ipp32u dec_keys[64]; /* array of keys for decryprion */
+ Ipp32u aesNI; /* AES instruction available */
+ Ipp32u safeInit; /* SafeInit performed */
+};
+
+struct _cpRijndael192 {
+ IppCtxId idCtx; /* Rijndael spec identifier */
+ int nk; /* security key length (words) */
+ int nb; /* data block size (words) */
+ int nr; /* number of rounds */
+ RijnCipher encoder; /* encoder/decoder */
+ RijnCipher decoder; /* entry point */
+ Ipp32u* pEncTbl; /* expanded S-boxes for */
+ Ipp32u* pDecTbl; /* encryption and decryption */
+ Ipp32u enc_keys[96]; /* array of keys for encryprion */
+ Ipp32u dec_keys[96]; /* array of keys for decryprion */
+ Ipp32u aesNI; /* AES instruction available */
+ Ipp32u safeInit; /* SafeInit performed */
+};
+
+struct _cpRijndael256 {
+ IppCtxId idCtx; /* Rijndael spec identifier */
+ int nk; /* security key length (words) */
+ int nb; /* data block size (words) */
+ int nr; /* number of rounds */
+ RijnCipher encoder; /* encoder/decoder */
+ RijnCipher decoder; /* entry point */
+ Ipp32u* pEncTbl; /* expanded S-boxes for */
+ Ipp32u* pDecTbl; /* encryption and decryption */
+ Ipp32u enc_keys[120]; /* array of keys for encryprion */
+ Ipp32u dec_keys[120]; /* array of keys for decryprion */
+ Ipp32u aesNI; /* AES instruction available */
+ Ipp32u safeInit; /* SafeInit performed */
+};
+
+
+/* alignment */
+#define RIJ_ALIGNMENT (16)
+
+#define MBS_RIJ128 (128/8) /* message block size (bytes) */
+#define MBS_RIJ192 (192/8)
+#define MBS_RIJ256 (256/8)
+
+#define SR (4) /* number of rows in STATE data */
+
+#define NB(msgBlks) ((msgBlks)/32) /* message block size (words) */
+ /* 4-word for 128-bits data block */
+ /* 6-word for 192-bits data block */
+ /* 8-word for 256-bits data block */
+
+#define NK(keybits) ((keybits)/32) /* key length (words): */
+#define NK128 NK(ippRijndaelKey128)/* 4-word for 128-bits security key */
+#define NK192 NK(ippRijndaelKey192)/* 6-word for 192-bits security key */
+#define NK256 NK(ippRijndaelKey256)/* 8-word for 256-bits security key */
+
+#define NR128_128 (10) /* number of rounds data: 128 bits key: 128 bits are used */
+#define NR128_192 (12) /* number of rounds data: 128 bits key: 192 bits are used */
+#define NR128_256 (14) /* number of rounds data: 128 bits key: 256 bits are used */
+#define NR192_128 (12) /* number of rounds data: 192 bits key: 128 bits are used */
+#define NR192_192 (12) /* number of rounds data: 192 bits key: 192 bits are used */
+#define NR192_256 (14) /* number of rounds data: 192 bits key: 256 bits are used */
+#define NR256_128 (14) /* number of rounds data: 256 bits key: 128 bits are used */
+#define NR256_192 (14) /* number of rounds data: 256 bits key: 192 bits are used */
+#define NR256_256 (14) /* number of rounds data: 256 bits key: 256 bits are used */
+
+/*
+// Useful macros
+*/
+#define RIJ_ID(ctx) ((ctx)->idCtx)
+#define RIJ_NB(ctx) ((ctx)->nb)
+#define RIJ_NK(ctx) ((ctx)->nk)
+#define RIJ_NR(ctx) ((ctx)->nr)
+#define RIJ_ENCODER(ctx) ((ctx)->encoder)
+#define RIJ_DECODER(ctx) ((ctx)->decoder)
+#define RIJ_ENC_SBOX(ctx) ((ctx)->pEncTbl)
+#define RIJ_DEC_SBOX(ctx) ((ctx)->pDecTbl)
+#define RIJ_EKEYS(ctx) (Ipp8u*)((ctx)->enc_keys)
+#define RIJ_DKEYS(ctx) (Ipp8u*)((ctx)->dec_keys)
+#define RIJ_AESNI(ctx) ((ctx)->aesNI)
+#define RIJ_SAFE_INIT(ctx) ((ctx)->safeInit)
+
+#define RIJ_ID_TEST(ctx) (RIJ_ID((ctx))==idCtxRijndael)
+
+/*
+// Internal functions
+*/
+#if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPOSITE_GF_)
+#define SafeEncrypt_RIJ128 OWNAPI(SafeEncrypt_RIJ128)
+ void SafeEncrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#define SafeDecrypt_RIJ128 OWNAPI(SafeDecrypt_RIJ128)
+ void SafeDecrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#endif
+
+#if (_ALG_AES_SAFE_==_ALG_AES_SAFE_COMPACT_SBOX_)
+#define Safe2Encrypt_RIJ128 OWNAPI(Safe2Encrypt_RIJ128)
+ void Safe2Encrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#define Safe2Decrypt_RIJ128 OWNAPI(Safe2Decrypt_RIJ128)
+ void Safe2Decrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#endif
+
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+#define Encrypt_RIJ128_AES_NI OWNAPI(Encrypt_RIJ128_AES_NI)
+ void Encrypt_RIJ128_AES_NI(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#define EncryptECB_RIJ128pipe_AES_NI OWNAPI(EncryptECB_RIJ128pipe_AES_NI)
+ void EncryptECB_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len);
+#define EncryptCBC_RIJ128_AES_NI OWNAPI(EncryptCBC_RIJ128_AES_NI)
+ void EncryptCBC_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, const Ipp8u* pIV);
+#define EncryptCTR_RIJ128pipe_AES_NI OWNAPI(EncryptCTR_RIJ128pipe_AES_NI)
+ void EncryptCTR_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, Ipp8u* pCtrValue, const Ipp8u* pCtrBitMask);
+#define EncryptStreamCTR32_AES_NI OWNAPI(EncryptStreamCTR32_AES_NI)
+ void EncryptStreamCTR32_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, Ipp8u* pCtrValue);
+
+#define EncryptCFB_RIJ128_AES_NI OWNAPI(EncryptCFB_RIJ128_AES_NI)
+ void EncryptCFB_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, int cfbBlkSize, const Ipp8u* pIV);
+#define EncryptCFB32_RIJ128_AES_NI OWNAPI(EncryptCFB32_RIJ128_AES_NI)
+ void EncryptCFB32_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, int cfbBlkSize, const Ipp8u* pIV);
+#define EncryptCFB128_RIJ128_AES_NI OWNAPI(EncryptCFB128_RIJ128_AES_NI)
+ void EncryptCFB128_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, const Ipp8u* pIV);
+#define EncryptOFB_RIJ128_AES_NI OWNAPI(EncryptOFB_RIJ128_AES_NI)
+ void EncryptOFB_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, int ofbBlkSize, Ipp8u* pIV);
+#define EncryptOFB128_RIJ128_AES_NI OWNAPI(EncryptOFB128_RIJ128_AES_NI)
+ void EncryptOFB128_RIJ128_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, Ipp8u* pIV);
+
+#define Decrypt_RIJ128_AES_NI OWNAPI(Decrypt_RIJ128_AES_NI)
+ void Decrypt_RIJ128_AES_NI(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
+#define DecryptECB_RIJ128pipe_AES_NI OWNAPI(DecryptECB_RIJ128pipe_AES_NI)
+ void DecryptECB_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len);
+#define DecryptCBC_RIJ128pipe_AES_NI OWNAPI(DecryptCBC_RIJ128pipe_AES_NI)
+ void DecryptCBC_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, const Ipp8u* pIV);
+#define DecryptCFB_RIJ128pipe_AES_NI OWNAPI(DecryptCFB_RIJ128pipe_AES_NI)
+ void DecryptCFB_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int cfbBlocks, int cfbBlkSize, const Ipp8u* pIV);
+#define DecryptCFB32_RIJ128pipe_AES_NI OWNAPI(DecryptCFB32_RIJ128pipe_AES_NI)
+ void DecryptCFB32_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int cfbBlocks, int cfbBlkSize, const Ipp8u* pIV);
+#define DecryptCFB128_RIJ128pipe_AES_NI OWNAPI(DecryptCFB128_RIJ128pipe_AES_NI)
+ void DecryptCFB128_RIJ128pipe_AES_NI(const Ipp8u* pSrc, Ipp8u* pDst, int nr, const Ipp8u* pKeys, int len, const Ipp8u* pIV);
+
+#define cpExpandAesKey_NI OWNAPI(cpExpandAesKey_NI)
+ void cpExpandAesKey_NI(const Ipp8u* pSecret, IppsAESSpec* pCtx);
+
+#define cpAESEncryptXTS_AES_NI OWNAPI(cpAESEncryptXTS_AES_NI)
+ void cpAESEncryptXTS_AES_NI(Ipp8u* outBlk, const Ipp8u* inpBlk, int nBlks, const Ipp8u* pRKey, int nr, Ipp8u* pTweak);
+#define cpAESDecryptXTS_AES_NI OWNAPI(cpAESDecryptXTS_AES_NI)
+ void cpAESDecryptXTS_AES_NI(Ipp8u* outBlk, const Ipp8u* inpBlk, int nBlks, const Ipp8u* pRKey, int nr, Ipp8u* pTweak);
+#endif
+
+#define ExpandRijndaelKey OWNAPI(ExpandRijndaelKey)
+ void ExpandRijndaelKey(const Ipp8u* pKey, int NK, int NB, int NR, int nKeys,
+ Ipp8u* pEncKeys, Ipp8u* pDecKeys);
+
+#if(_IPP>_IPP_PX || _IPP32E>_IPP32E_PX)
+#define Touch_SubsDword_8uT OWNAPI(Touch_SubsDword_8uT)
+ Ipp32u Touch_SubsDword_8uT(Ipp32u inp, const Ipp8u* pTbl, int tblLen);
+#endif
+
+#endif /* _PCP_RIJ_H */
diff --git a/ext/ipp/sources/ippcp/pcprij128safe.h b/ext/ipp/sources/ippcp/pcprij128safe.h
new file mode 100644
index 0000000..a53cb13
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprij128safe.h
@@ -0,0 +1,142 @@
+/*******************************************************************************
+* Copyright 2007-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Safe Rijndael Encrypt, Decrypt
+//
+//
+*/
+
+#if !defined(_PCP_RIJ_SAFE_H)
+#define _PCP_RIJ_SAFE_H
+
+#include "owncp.h"
+#include "pcprijtables.h"
+#include "pcpbnuimpl.h"
+
+#if defined _PCP_RIJ_SAFE_OLD
+/* old version */
+#define TransformByte OWNAPI(TransformByte)
+Ipp8u TransformByte(Ipp8u x, const Ipp8u Transformation[]);
+
+#define TransformNative2Composite OWNAPI(TransformNative2Composite)
+#define TransformComposite2Native OWNAPI(TransformComposite2Native)
+
+void TransformNative2Composite(Ipp8u out[16], const Ipp8u inp[16]);
+void TransformComposite2Native(Ipp8u out[16], const Ipp8u inp[16]);
+
+#define InverseComposite OWNAPI(InverseComposite)
+Ipp8u InverseComposite(Ipp8u x);
+
+#define AddRoundKey OWNAPI(AddRoundKey)
+void AddRoundKey(Ipp8u out[], const Ipp8u inp[], const Ipp8u pKey[]);
+#endif
+
+
+#if !defined _PCP_RIJ_SAFE_OLD
+/* new version */
+#define TransformNative2Composite OWNAPI(TransformNative2Composite)
+#define TransformComposite2Native OWNAPI(TransformComposite2Native)
+
+void TransformNative2Composite(Ipp8u out[16], const Ipp8u inp[16]);
+void TransformComposite2Native(Ipp8u out[16], const Ipp8u inp[16]);
+
+/* add round key operation */
+__INLINE void AddRoundKey(Ipp8u out[16], const Ipp8u inp[16], const Ipp8u rkey[16])
+{
+ ((Ipp64u*)out)[0] = ((Ipp64u*)inp)[0] ^ ((Ipp64u*)rkey)[0];
+ ((Ipp64u*)out)[1] = ((Ipp64u*)inp)[1] ^ ((Ipp64u*)rkey)[1];
+}
+
+/* add logs of GF(2^4) elements
+// the exp table has been build matched for that implementation
+*/
+__INLINE Ipp8u AddLogGF16(Ipp8u loga, Ipp8u logb)
+{
+ //Ipp8u s = loga+logb;
+ //return (s>2*14)? 15 : (s>14)? s-15 : s;
+ Ipp8u s = loga+logb;
+ Ipp8u delta = ((0xF-1)-s)>>7;
+ s -= delta;
+ s |= 0-(s>>7);
+ return s & (0xF);
+}
+#endif
+
+#define SELECTION_BITS ((sizeof(BNU_CHUNK_T)/sizeof(Ipp8u)) -1)
+
+#if defined(__INTEL_COMPILER)
+__INLINE Ipp8u getSboxValue(Ipp8u x)
+{
+ BNU_CHUNK_T selection = 0;
+ const BNU_CHUNK_T* SboxEntry = (BNU_CHUNK_T*)RijEncSbox;
+
+ BNU_CHUNK_T i_sel = x / sizeof(BNU_CHUNK_T); /* selection index */
+ BNU_CHUNK_T i;
+ for (i = 0; i<sizeof(RijEncSbox) / sizeof(BNU_CHUNK_T); i++) {
+ BNU_CHUNK_T mask = (i == i_sel) ? (BNU_CHUNK_T)(-1) : 0; /* ipp and IPP build specific avoid jump instruction here */
+ selection |= SboxEntry[i] & mask;
+ }
+ selection >>= (x & SELECTION_BITS) * 8;
+ return (Ipp8u)(selection & 0xFF);
+}
+
+#else
+#include "pcpmask_ct.h"
+__INLINE Ipp8u getSboxValue(Ipp8u x)
+{
+ BNU_CHUNK_T selection = 0;
+ const BNU_CHUNK_T* SboxEntry = (BNU_CHUNK_T*)RijEncSbox;
+
+ Ipp32u _x = x / sizeof(BNU_CHUNK_T);
+ Ipp32u i;
+ for (i = 0; i<sizeof(RijEncSbox) / sizeof(BNU_CHUNK_T); i++) {
+ BNS_CHUNK_T mask = cpIsEqu_ct(_x, i);
+ selection |= SboxEntry[i] & mask;
+ }
+ selection >>= (x & SELECTION_BITS) * 8;
+ return (Ipp8u)(selection & 0xFF);
+}
+#endif
+
+#endif /* _PCP_RIJ_SAFE_H */
diff --git a/ext/ipp/sources/ippcp/pcprij128safe2.h b/ext/ipp/sources/ippcp/pcprij128safe2.h
new file mode 100644
index 0000000..bed4f42
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprij128safe2.h
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Safe Rijndael Encrypt, Decrypt
+//
+//
+*/
+
+#if !defined(_PCP_RIJ_SAFE2_H)
+#define _PCP_RIJ_SAFE2_H
+
+// transpose 4x4 Ipp8u matrix
+#define TRANSPOSE(out, inp) \
+ (out)[ 0] = (inp)[ 0]; \
+ (out)[ 4] = (inp)[ 1]; \
+ (out)[ 8] = (inp)[ 2]; \
+ (out)[12] = (inp)[ 3]; \
+ \
+ (out)[ 1] = (inp)[ 4]; \
+ (out)[ 5] = (inp)[ 5]; \
+ (out)[ 9] = (inp)[ 6]; \
+ (out)[13] = (inp)[ 7]; \
+ \
+ (out)[ 2] = (inp)[ 8]; \
+ (out)[ 6] = (inp)[ 9]; \
+ (out)[10] = (inp)[10]; \
+ (out)[14] = (inp)[11]; \
+ \
+ (out)[ 3] = (inp)[12]; \
+ (out)[ 7] = (inp)[13]; \
+ (out)[11] = (inp)[14]; \
+ (out)[15] = (inp)[15]
+
+__INLINE void XorRoundKey(Ipp32u* state, const Ipp32u* RoundKey)
+{
+ state[0] ^= RoundKey[0];
+ state[1] ^= RoundKey[1];
+ state[2] ^= RoundKey[2];
+ state[3] ^= RoundKey[3];
+}
+
+// xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b}
+__INLINE Ipp32u mask4(Ipp32u x)
+{
+ x &= 0x80808080;
+ return (Ipp32u)((x<<1) - (x>>7));
+}
+
+__INLINE Ipp32u xtime4(Ipp32u x)
+{
+ Ipp32u t = (x+x) &0xFEFEFEFE;
+ t ^= mask4(x) & 0x1B1B1B1B;
+ return t;
+}
+
+#endif /* _PCP_RIJ_SAFE2_H */
diff --git a/ext/ipp/sources/ippcp/pcprijtables.h b/ext/ipp/sources/ippcp/pcprijtables.h
new file mode 100644
index 0000000..199114d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprijtables.h
@@ -0,0 +1,220 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Rijndael Tables Declarations
+//
+//
+*/
+
+#if !defined(_PCP_RIJTBLES_H)
+#define _PCP_RIJTBLES_H
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcprij.h"
+
+/*
+// GF(256) multiplication operations
+*/
+#define gf_m2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY))
+#define gf_m4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))
+#define gf_m8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \
+ ^ (((x>>5) & 4) * WPOLY))
+#define gf_m1(x) ((x))
+#define gf_m3(x) (gf_m2(x) ^ x)
+#define gf_m9(x) (gf_m8(x) ^ x)
+#define gf_mB(x) (gf_m8(x) ^ gf_m2(x) ^ x)
+#define gf_mD(x) (gf_m8(x) ^ gf_m4(x) ^ x)
+#define gf_mE(x) (gf_m8(x) ^ gf_m4(x) ^ gf_m2(x))
+
+/*
+// The following particular transformations
+// are used for create Encryption Tables
+*/
+#define fwd_t0(x) BYTES_TO_WORD(gf_m2(x), gf_m1(x), gf_m1(x), gf_m3(x))
+#define fwd_t1(x) BYTES_TO_WORD(gf_m3(x), gf_m2(x), gf_m1(x), gf_m1(x))
+#define fwd_t2(x) BYTES_TO_WORD(gf_m1(x), gf_m3(x), gf_m2(x), gf_m1(x))
+#define fwd_t3(x) BYTES_TO_WORD(gf_m1(x), gf_m1(x), gf_m3(x), gf_m2(x))
+
+/*
+// The following particular transformations
+// are used for create Decryption Tables
+*/
+#define inv_t0(x) BYTES_TO_WORD(gf_mE(x), gf_m9(x), gf_mD(x), gf_mB(x))
+#define inv_t1(x) BYTES_TO_WORD(gf_mB(x), gf_mE(x), gf_m9(x), gf_mD(x))
+#define inv_t2(x) BYTES_TO_WORD(gf_mD(x), gf_mB(x), gf_mE(x), gf_m9(x))
+#define inv_t3(x) BYTES_TO_WORD(gf_m9(x), gf_mD(x), gf_mB(x), gf_mE(x))
+
+#define exp_b3(x) BYTES_TO_WORD(0, 0, 0, (x))
+#define exp_b2(x) BYTES_TO_WORD(0, 0, (x),0)
+#define exp_b1(x) BYTES_TO_WORD(0, (x),0, 0)
+#define exp_b0(x) BYTES_TO_WORD((x),0, 0, 0)
+
+/*
+// The following particular transformations
+// are used for create pure Encryption/Decryption Sboxes
+*/
+#define none_t(x) (x)
+
+
+/*
+// Just sequence of byte, beginning 0x00 upto 0xff
+// (be parametrized by any transformation 't')
+*/
+#define LINE(t) \
+ t(0x00), t(0x01), t(0x02), t(0x03), t(0x04), t(0x05), t(0x06), t(0x07),\
+ t(0x08), t(0x09), t(0x0a), t(0x0b), t(0x0c), t(0x0d), t(0x0e), t(0x0f),\
+ t(0x10), t(0x11), t(0x12), t(0x13), t(0x14), t(0x15), t(0x16), t(0x17),\
+ t(0x18), t(0x19), t(0x1a), t(0x1b), t(0x1c), t(0x1d), t(0x1e), t(0x1f),\
+ t(0x20), t(0x21), t(0x22), t(0x23), t(0x24), t(0x25), t(0x26), t(0x27),\
+ t(0x28), t(0x29), t(0x2a), t(0x2b), t(0x2c), t(0x2d), t(0x2e), t(0x2f),\
+ t(0x30), t(0x31), t(0x32), t(0x33), t(0x34), t(0x35), t(0x36), t(0x37),\
+ t(0x38), t(0x39), t(0x3a), t(0x3b), t(0x3c), t(0x3d), t(0x3e), t(0x3f),\
+ t(0x40), t(0x41), t(0x42), t(0x43), t(0x44), t(0x45), t(0x46), t(0x47),\
+ t(0x48), t(0x49), t(0x4a), t(0x4b), t(0x4c), t(0x4d), t(0x4e), t(0x4f),\
+ t(0x50), t(0x51), t(0x52), t(0x53), t(0x54), t(0x55), t(0x56), t(0x57),\
+ t(0x58), t(0x59), t(0x5a), t(0x5b), t(0x5c), t(0x5d), t(0x5e), t(0x5f),\
+ t(0x60), t(0x61), t(0x62), t(0x63), t(0x64), t(0x65), t(0x66), t(0x67),\
+ t(0x68), t(0x69), t(0x6a), t(0x6b), t(0x6c), t(0x6d), t(0x6e), t(0x6f),\
+ t(0x70), t(0x71), t(0x72), t(0x73), t(0x74), t(0x75), t(0x76), t(0x77),\
+ t(0x78), t(0x79), t(0x7a), t(0x7b), t(0x7c), t(0x7d), t(0x7e), t(0x7f),\
+ t(0x80), t(0x81), t(0x82), t(0x83), t(0x84), t(0x85), t(0x86), t(0x87),\
+ t(0x88), t(0x89), t(0x8a), t(0x8b), t(0x8c), t(0x8d), t(0x8e), t(0x8f),\
+ t(0x90), t(0x91), t(0x92), t(0x93), t(0x94), t(0x95), t(0x96), t(0x97),\
+ t(0x98), t(0x99), t(0x9a), t(0x9b), t(0x9c), t(0x9d), t(0x9e), t(0x9f),\
+ t(0xa0), t(0xa1), t(0xa2), t(0xa3), t(0xa4), t(0xa5), t(0xa6), t(0xa7),\
+ t(0xa8), t(0xa9), t(0xaa), t(0xab), t(0xac), t(0xad), t(0xae), t(0xaf),\
+ t(0xb0), t(0xb1), t(0xb2), t(0xb3), t(0xb4), t(0xb5), t(0xb6), t(0xb7),\
+ t(0xb8), t(0xb9), t(0xba), t(0xbb), t(0xbc), t(0xbd), t(0xbe), t(0xbf),\
+ t(0xc0), t(0xc1), t(0xc2), t(0xc3), t(0xc4), t(0xc5), t(0xc6), t(0xc7),\
+ t(0xc8), t(0xc9), t(0xca), t(0xcb), t(0xcc), t(0xcd), t(0xce), t(0xcf),\
+ t(0xd0), t(0xd1), t(0xd2), t(0xd3), t(0xd4), t(0xd5), t(0xd6), t(0xd7),\
+ t(0xd8), t(0xd9), t(0xda), t(0xdb), t(0xdc), t(0xdd), t(0xde), t(0xdf),\
+ t(0xe0), t(0xe1), t(0xe2), t(0xe3), t(0xe4), t(0xe5), t(0xe6), t(0xe7),\
+ t(0xe8), t(0xe9), t(0xea), t(0xeb), t(0xec), t(0xed), t(0xee), t(0xef),\
+ t(0xf0), t(0xf1), t(0xf2), t(0xf3), t(0xf4), t(0xf5), t(0xf6), t(0xf7),\
+ t(0xf8), t(0xf9), t(0xfa), t(0xfb), t(0xfc), t(0xfd), t(0xfe), t(0xff)
+
+/*
+// Encrypt/Decrypt S-box data
+// (be parametrized by any transformation 't')
+*/
+#define ENC_SBOX(t) \
+ t(0x63), t(0x7c), t(0x77), t(0x7b), t(0xf2), t(0x6b), t(0x6f), t(0xc5),\
+ t(0x30), t(0x01), t(0x67), t(0x2b), t(0xfe), t(0xd7), t(0xab), t(0x76),\
+ t(0xca), t(0x82), t(0xc9), t(0x7d), t(0xfa), t(0x59), t(0x47), t(0xf0),\
+ t(0xad), t(0xd4), t(0xa2), t(0xaf), t(0x9c), t(0xa4), t(0x72), t(0xc0),\
+ t(0xb7), t(0xfd), t(0x93), t(0x26), t(0x36), t(0x3f), t(0xf7), t(0xcc),\
+ t(0x34), t(0xa5), t(0xe5), t(0xf1), t(0x71), t(0xd8), t(0x31), t(0x15),\
+ t(0x04), t(0xc7), t(0x23), t(0xc3), t(0x18), t(0x96), t(0x05), t(0x9a),\
+ t(0x07), t(0x12), t(0x80), t(0xe2), t(0xeb), t(0x27), t(0xb2), t(0x75),\
+ t(0x09), t(0x83), t(0x2c), t(0x1a), t(0x1b), t(0x6e), t(0x5a), t(0xa0),\
+ t(0x52), t(0x3b), t(0xd6), t(0xb3), t(0x29), t(0xe3), t(0x2f), t(0x84),\
+ t(0x53), t(0xd1), t(0x00), t(0xed), t(0x20), t(0xfc), t(0xb1), t(0x5b),\
+ t(0x6a), t(0xcb), t(0xbe), t(0x39), t(0x4a), t(0x4c), t(0x58), t(0xcf),\
+ t(0xd0), t(0xef), t(0xaa), t(0xfb), t(0x43), t(0x4d), t(0x33), t(0x85),\
+ t(0x45), t(0xf9), t(0x02), t(0x7f), t(0x50), t(0x3c), t(0x9f), t(0xa8),\
+ t(0x51), t(0xa3), t(0x40), t(0x8f), t(0x92), t(0x9d), t(0x38), t(0xf5),\
+ t(0xbc), t(0xb6), t(0xda), t(0x21), t(0x10), t(0xff), t(0xf3), t(0xd2),\
+ t(0xcd), t(0x0c), t(0x13), t(0xec), t(0x5f), t(0x97), t(0x44), t(0x17),\
+ t(0xc4), t(0xa7), t(0x7e), t(0x3d), t(0x64), t(0x5d), t(0x19), t(0x73),\
+ t(0x60), t(0x81), t(0x4f), t(0xdc), t(0x22), t(0x2a), t(0x90), t(0x88),\
+ t(0x46), t(0xee), t(0xb8), t(0x14), t(0xde), t(0x5e), t(0x0b), t(0xdb),\
+ t(0xe0), t(0x32), t(0x3a), t(0x0a), t(0x49), t(0x06), t(0x24), t(0x5c),\
+ t(0xc2), t(0xd3), t(0xac), t(0x62), t(0x91), t(0x95), t(0xe4), t(0x79),\
+ t(0xe7), t(0xc8), t(0x37), t(0x6d), t(0x8d), t(0xd5), t(0x4e), t(0xa9),\
+ t(0x6c), t(0x56), t(0xf4), t(0xea), t(0x65), t(0x7a), t(0xae), t(0x08),\
+ t(0xba), t(0x78), t(0x25), t(0x2e), t(0x1c), t(0xa6), t(0xb4), t(0xc6),\
+ t(0xe8), t(0xdd), t(0x74), t(0x1f), t(0x4b), t(0xbd), t(0x8b), t(0x8a),\
+ t(0x70), t(0x3e), t(0xb5), t(0x66), t(0x48), t(0x03), t(0xf6), t(0x0e),\
+ t(0x61), t(0x35), t(0x57), t(0xb9), t(0x86), t(0xc1), t(0x1d), t(0x9e),\
+ t(0xe1), t(0xf8), t(0x98), t(0x11), t(0x69), t(0xd9), t(0x8e), t(0x94),\
+ t(0x9b), t(0x1e), t(0x87), t(0xe9), t(0xce), t(0x55), t(0x28), t(0xdf),\
+ t(0x8c), t(0xa1), t(0x89), t(0x0d), t(0xbf), t(0xe6), t(0x42), t(0x68),\
+ t(0x41), t(0x99), t(0x2d), t(0x0f), t(0xb0), t(0x54), t(0xbb), t(0x16)
+
+#define DEC_SBOX(t) \
+ t(0x52), t(0x09), t(0x6a), t(0xd5), t(0x30), t(0x36), t(0xa5), t(0x38),\
+ t(0xbf), t(0x40), t(0xa3), t(0x9e), t(0x81), t(0xf3), t(0xd7), t(0xfb),\
+ t(0x7c), t(0xe3), t(0x39), t(0x82), t(0x9b), t(0x2f), t(0xff), t(0x87),\
+ t(0x34), t(0x8e), t(0x43), t(0x44), t(0xc4), t(0xde), t(0xe9), t(0xcb),\
+ t(0x54), t(0x7b), t(0x94), t(0x32), t(0xa6), t(0xc2), t(0x23), t(0x3d),\
+ t(0xee), t(0x4c), t(0x95), t(0x0b), t(0x42), t(0xfa), t(0xc3), t(0x4e),\
+ t(0x08), t(0x2e), t(0xa1), t(0x66), t(0x28), t(0xd9), t(0x24), t(0xb2),\
+ t(0x76), t(0x5b), t(0xa2), t(0x49), t(0x6d), t(0x8b), t(0xd1), t(0x25),\
+ t(0x72), t(0xf8), t(0xf6), t(0x64), t(0x86), t(0x68), t(0x98), t(0x16),\
+ t(0xd4), t(0xa4), t(0x5c), t(0xcc), t(0x5d), t(0x65), t(0xb6), t(0x92),\
+ t(0x6c), t(0x70), t(0x48), t(0x50), t(0xfd), t(0xed), t(0xb9), t(0xda),\
+ t(0x5e), t(0x15), t(0x46), t(0x57), t(0xa7), t(0x8d), t(0x9d), t(0x84),\
+ t(0x90), t(0xd8), t(0xab), t(0x00), t(0x8c), t(0xbc), t(0xd3), t(0x0a),\
+ t(0xf7), t(0xe4), t(0x58), t(0x05), t(0xb8), t(0xb3), t(0x45), t(0x06),\
+ t(0xd0), t(0x2c), t(0x1e), t(0x8f), t(0xca), t(0x3f), t(0x0f), t(0x02),\
+ t(0xc1), t(0xaf), t(0xbd), t(0x03), t(0x01), t(0x13), t(0x8a), t(0x6b),\
+ t(0x3a), t(0x91), t(0x11), t(0x41), t(0x4f), t(0x67), t(0xdc), t(0xea),\
+ t(0x97), t(0xf2), t(0xcf), t(0xce), t(0xf0), t(0xb4), t(0xe6), t(0x73),\
+ t(0x96), t(0xac), t(0x74), t(0x22), t(0xe7), t(0xad), t(0x35), t(0x85),\
+ t(0xe2), t(0xf9), t(0x37), t(0xe8), t(0x1c), t(0x75), t(0xdf), t(0x6e),\
+ t(0x47), t(0xf1), t(0x1a), t(0x71), t(0x1d), t(0x29), t(0xc5), t(0x89),\
+ t(0x6f), t(0xb7), t(0x62), t(0x0e), t(0xaa), t(0x18), t(0xbe), t(0x1b),\
+ t(0xfc), t(0x56), t(0x3e), t(0x4b), t(0xc6), t(0xd2), t(0x79), t(0x20),\
+ t(0x9a), t(0xdb), t(0xc0), t(0xfe), t(0x78), t(0xcd), t(0x5a), t(0xf4),\
+ t(0x1f), t(0xdd), t(0xa8), t(0x33), t(0x88), t(0x07), t(0xc7), t(0x31),\
+ t(0xb1), t(0x12), t(0x10), t(0x59), t(0x27), t(0x80), t(0xec), t(0x5f),\
+ t(0x60), t(0x51), t(0x7f), t(0xa9), t(0x19), t(0xb5), t(0x4a), t(0x0d),\
+ t(0x2d), t(0xe5), t(0x7a), t(0x9f), t(0x93), t(0xc9), t(0x9c), t(0xef),\
+ t(0xa0), t(0xe0), t(0x3b), t(0x4d), t(0xae), t(0x2a), t(0xf5), t(0xb0),\
+ t(0xc8), t(0xeb), t(0xbb), t(0x3c), t(0x83), t(0x53), t(0x99), t(0x61),\
+ t(0x17), t(0x2b), t(0x04), t(0x7e), t(0xba), t(0x77), t(0xd6), t(0x26),\
+ t(0xe1), t(0x69), t(0x14), t(0x63), t(0x55), t(0x21), t(0x0c), t(0x7d),
+
+/*
+// Internal cipher tables
+*/
+extern const __ALIGN64 Ipp8u RijEncSbox[256]; /* pure encryption S-box */
+extern const __ALIGN64 Ipp8u RijDecSbox[256]; /* pure decryption S-box */
+
+extern const __ALIGN16 Ipp32u RijEncTbl[5][256]; /* precomputed encryption tables */
+extern const __ALIGN16 Ipp32u RijDecTbl[5][256]; /* precomputed decryption tables */
+
+#endif /* _PCP_RIJTBLES_H */
diff --git a/ext/ipp/sources/ippcp/pcprsa_emsa_pkcs1v15.h b/ext/ipp/sources/ippcp/pcprsa_emsa_pkcs1v15.h
new file mode 100644
index 0000000..775124d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_emsa_pkcs1v15.h
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSASSA-PKCS-v1_5
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpngrsa.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+static int EMSA_PKCSv15(const Ipp8u* msgDg, int lenMsgDg,
+ const Ipp8u* fixPS, int lenFixPS,
+ Ipp8u* pEM, int lenEM)
+{
+ /*
+ // encoded message format:
+ // EM = 00 || 01 || PS=(FF..FF) || 00 || T
+ // T = fixPS || msgDg
+ // len(PS) >= 8
+ */
+ int tLen = lenFixPS + lenMsgDg;
+
+ if (lenEM >= tLen + 11) {
+ int psLen = lenEM - 3 - tLen;
+
+ PaddBlock(0xFF, pEM, lenEM);
+ pEM[0] = 0x00;
+ pEM[1] = 0x01;
+ pEM[2 + psLen] = 0x00;
+ CopyBlock(fixPS, pEM + 3 + psLen, lenFixPS);
+ CopyBlock(msgDg, pEM + 3 + psLen + lenFixPS, lenMsgDg);
+ return 1;
+ }
+ else
+ return 0; /* encoded message length too long */
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_generatesing_pkcs1v15.h b/ext/ipp/sources/ippcp/pcprsa_generatesing_pkcs1v15.h
new file mode 100644
index 0000000..842e3bc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_generatesing_pkcs1v15.h
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSASSA-PKCS-v1_5
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpngrsa.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+#include "pcprsa_emsa_pkcs1v15.h"
+
+static int GenerateSing(const Ipp8u* pMsg, int msgLen, /* message representation */
+ const Ipp8u* pSalt, int saltLen, /* fied string */
+ Ipp8u* pSign,
+ const IppsRSAPrivateKeyState* pPrvKey,
+ const IppsRSAPublicKeyState* pPubKey,
+ BNU_CHUNK_T* pBuffer)
+{
+ /* size of RSA modulus in bytes and chunks */
+ cpSize rsaBits = RSA_PRV_KEY_BITSIZE_N(pPrvKey);
+ cpSize k = BITS2WORD8_SIZE(rsaBits);
+ cpSize nsN = BITS_BNU_CHUNK(rsaBits);
+
+ /* EMSA-PKCS-v1_5 encoding */
+ int result = EMSA_PKCSv15(pMsg, msgLen, pSalt, saltLen, pSign, k);
+
+ if (result) {
+ /* temporary BNs */
+ __ALIGN8 IppsBigNumState bnC;
+ __ALIGN8 IppsBigNumState bnP;
+
+ /* make BNs */
+ BN_Make(pBuffer, pBuffer + nsN + 1, nsN, &bnC);
+ pBuffer += (nsN + 1) * 2;
+ BN_Make(pBuffer, pBuffer + nsN + 1, nsN, &bnP);
+ pBuffer += (nsN + 1) * 2;
+
+ /*
+ // private-key operation
+ */
+ ippsSetOctString_BN(pSign, k, &bnC);
+
+ if (RSA_PRV_KEY1_VALID_ID(pPrvKey))
+ gsRSAprv_cipher(&bnP, &bnC, pPrvKey, pBuffer);
+ else
+ gsRSAprv_cipher_crt(&bnP, &bnC, pPrvKey, pBuffer);
+
+ ippsGetOctString_BN(pSign, k, &bnP);
+
+ /* check the result before send it out (fault attack mitigatioin) */
+ if (pPubKey) {
+ gsRSApub_cipher(&bnP, &bnP, pPubKey, pBuffer);
+
+ /* check signature before send it out (fault attack mitigatioin) */
+ if (0 != cpBN_cmp(&bnP, &bnC)) {
+ PaddBlock(0, pSign, k);
+ result = 0;
+ }
+ }
+ }
+
+ return result;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_getdefmeth_priv.h b/ext/ipp/sources/ippcp/pcprsa_getdefmeth_priv.h
new file mode 100644
index 0000000..45217f8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_getdefmeth_priv.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+*/
+
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpngrsa.h"
+#include "pcpngrsamethod.h"
+
+static gsMethod_RSA* getDefaultMethod_RSA_private(int modulusBitSize)
+{
+ gsMethod_RSA* m;
+
+#if(_IPP32E>=_IPP32E_K0)
+ m = IsFeatureEnabled(ippCPUID_AVX512IFMA) ? gsMethod_RSA_avx512_private() : gsMethod_RSA_avx2_private();
+
+#elif(_IPP32E>=_IPP32E_L9)
+ m = IsFeatureEnabled(ippCPUID_ADCOX) ? gsMethod_RSA_gpr_private() : gsMethod_RSA_avx2_private();
+
+#elif(_IPP>=_IPP_W7)
+ m = gsMethod_RSA_sse2_private();
+
+#else
+ m = gsMethod_RSA_gpr_private();
+#endif
+
+ if (!(m->loModulusBisize <= modulusBitSize && modulusBitSize <= m->hiModulusBisize))
+ m = gsMethod_RSA_gpr_private();
+ return m;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_getdefmeth_pub.h b/ext/ipp/sources/ippcp/pcprsa_getdefmeth_pub.h
new file mode 100644
index 0000000..f61cf28
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_getdefmeth_pub.h
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+*/
+
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcpngrsa.h"
+#include "pcpngrsamethod.h"
+
+
+/* get default method based on CPU's features */
+static gsMethod_RSA* getDefaultMethod_RSA_public(int modulusBitSize)
+{
+ gsMethod_RSA* m;
+
+#if(_IPP32E>=_IPP32E_K0)
+ m = IsFeatureEnabled(ippCPUID_AVX512IFMA) ? gsMethod_RSA_avx512_public() : gsMethod_RSA_avx2_public();
+#elif(_IPP32E>=_IPP32E_L9)
+ m = gsMethod_RSA_avx2_public();
+#elif(_IPP>=_IPP_W7)
+ m = gsMethod_RSA_sse2_public();
+#else
+ m = gsMethod_RSA_gpr_public();
+#endif
+
+ if (!(m->loModulusBisize <= modulusBitSize && modulusBitSize <= m->hiModulusBisize))
+ m = gsMethod_RSA_gpr_public();
+ return m;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_pkcs1c15_data.h b/ext/ipp/sources/ippcp/pcprsa_pkcs1c15_data.h
new file mode 100644
index 0000000..a2b31f0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_pkcs1c15_data.h
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSASSA-PKCS-v1_5
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpngrsa.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+/*
+// The DER encoding T of the DigestInfo value is equal to the following (see PKCS-1v2-2):
+*/
+static const Ipp8u SHA1_fixPS[] = "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14";
+static const Ipp8u SHA224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c";
+static const Ipp8u SHA256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20";
+static const Ipp8u SHA384_fixPS[] = "\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30";
+static const Ipp8u SHA512_fixPS[] = "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40";
+static const Ipp8u MD5_fixPS[] = "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10";
+static const Ipp8u SHA512_224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x05\x05\x00\x04\x1c";
+static const Ipp8u SHA512_256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20";
+
+typedef struct {
+ const Ipp8u* pSalt;
+ int saltLen;
+} SaltInfo;
+
+static SaltInfo pksc15_salt[ippHashAlg_MaxNo] = {
+ { NULL, 0 },
+ { SHA1_fixPS, sizeof(SHA1_fixPS) - 1 },
+ { SHA256_fixPS, sizeof(SHA256_fixPS) - 1 },
+ { SHA224_fixPS, sizeof(SHA224_fixPS) - 1 },
+ { SHA512_fixPS, sizeof(SHA512_fixPS) - 1 },
+ { SHA384_fixPS, sizeof(SHA384_fixPS) - 1 },
+ { MD5_fixPS, sizeof(MD5_fixPS) - 1 },
+ { NULL, 0 },
+ { SHA512_224_fixPS, sizeof(SHA512_224_fixPS) - 1 },
+ { SHA512_256_fixPS, sizeof(SHA512_256_fixPS) - 1 },
+};
diff --git a/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey1.h b/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey1.h
new file mode 100644
index 0000000..8c2aaba
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey1.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+*/
+
+static int cpSizeof_RSA_privateKey1(int rsaModulusBitSize, int privateExpBitSize)
+{
+ int prvExpLen = BITS_BNU_CHUNK(privateExpBitSize);
+ int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize);
+ int montNsize;
+ rsaMontExpGetSize(modulusLen32, &montNsize);
+
+ return sizeof(IppsRSAPrivateKeyState)
+ + prvExpLen * sizeof(BNU_CHUNK_T)
+ + sizeof(BNU_CHUNK_T) - 1
+ + montNsize
+ + (RSA_PRIVATE_KEY_ALIGNMENT - 1);
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey2.h b/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey2.h
new file mode 100644
index 0000000..aff0849
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_sizeof_privkey2.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+*/
+
+static int cpSizeof_RSA_privateKey2(int factorPbitSize, int factorQbitSize)
+{
+ int factorPlen = BITS_BNU_CHUNK(factorPbitSize);
+ int factorQlen = BITS_BNU_CHUNK(factorQbitSize);
+ int factorPlen32 = BITS2WORD32_SIZE(factorPbitSize);
+ int factorQlen32 = BITS2WORD32_SIZE(factorQbitSize);
+ int rsaModulusLen32 = BITS2WORD32_SIZE(factorPbitSize + factorQbitSize);
+ int montPsize;
+ int montQsize;
+ int montNsize;
+ rsaMontExpGetSize(factorPlen32, &montPsize);
+ rsaMontExpGetSize(factorQlen32, &montQsize);
+ rsaMontExpGetSize(rsaModulusLen32, &montNsize);
+
+ return sizeof(IppsRSAPrivateKeyState)
+ + factorPlen * sizeof(BNU_CHUNK_T) /* dp slot */
+ + factorQlen * sizeof(BNU_CHUNK_T) /* dq slot */
+ + factorPlen * sizeof(BNU_CHUNK_T) /* qinv slot */
+ + sizeof(BNU_CHUNK_T) - 1
+ + montPsize
+ + montQsize
+ + montNsize
+ + (RSA_PRIVATE_KEY_ALIGNMENT - 1);
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcprsa_sizeof_pubkey.h b/ext/ipp/sources/ippcp/pcprsa_sizeof_pubkey.h
new file mode 100644
index 0000000..e0fe1ad
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_sizeof_pubkey.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSA Functions
+//
+*/
+
+/* compute size of RSA public key context */
+static int cpSizeof_RSA_publicKey(int rsaModulusBitSize, int publicExpBitSize)
+{
+ int pubExpLen = BITS_BNU_CHUNK(publicExpBitSize);
+ int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize);
+ int montNsize;
+ rsaMontExpGetSize(modulusLen32, &montNsize);
+
+ return sizeof(IppsRSAPublicKeyState)
+ + pubExpLen*sizeof(BNU_CHUNK_T)
+ + sizeof(BNU_CHUNK_T)-1
+ + montNsize
+ + (RSA_PUBLIC_KEY_ALIGNMENT-1);
+}
diff --git a/ext/ipp/sources/ippcp/pcprsa_verifysing_pkcs1v15.h b/ext/ipp/sources/ippcp/pcprsa_verifysing_pkcs1v15.h
new file mode 100644
index 0000000..1866046
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcprsa_verifysing_pkcs1v15.h
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// RSASSA-PKCS-v1_5
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpngrsa.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+#include "pcprsa_emsa_pkcs1v15.h"
+
+static int VerifySing(const Ipp8u* pMsg, int msgLen, /* message representation */
+ const Ipp8u* pSalt, int saltLen, /* fied string */
+ const Ipp8u* pSign,
+ int* pIsValid,
+ const IppsRSAPublicKeyState* pKey,
+ BNU_CHUNK_T* pBuffer)
+{
+ /* size of RSA modulus in bytes and chunks */
+ cpSize rsaBits = RSA_PUB_KEY_BITSIZE_N(pKey);
+ cpSize k = BITS2WORD8_SIZE(rsaBits);
+ cpSize nsN = BITS_BNU_CHUNK(rsaBits);
+
+ /* temporary BNs */
+ __ALIGN8 IppsBigNumState bnC;
+ __ALIGN8 IppsBigNumState bnP;
+
+ /* make BNs */
+ BN_Make(pBuffer, pBuffer + nsN + 1, nsN, &bnC);
+ pBuffer += (nsN + 1) * 2;
+ BN_Make(pBuffer, pBuffer + nsN + 1, nsN, &bnP);
+ pBuffer += (nsN + 1) * 2;
+
+ /*
+ // public-key operation
+ */
+ ippsSetOctString_BN(pSign, k, &bnP);
+ gsRSApub_cipher(&bnC, &bnP, pKey, pBuffer);
+
+ /* convert EM into the string */
+ ippsGetOctString_BN((Ipp8u*)(BN_BUFFER(&bnC)), k, &bnC);
+
+ /* EMSA-PKCS-v1_5 encoding */
+ if (EMSA_PKCSv15(pMsg, msgLen, pSalt, saltLen, (Ipp8u*)(BN_NUMBER(&bnC)), k)) {
+ *pIsValid = 1 == EquBlock((Ipp8u*)(BN_BUFFER(&bnC)), (Ipp8u*)(BN_NUMBER(&bnC)), k);
+ return 1;
+ }
+ else
+ return 0;
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpscramble.h b/ext/ipp/sources/ippcp/pcpscramble.h
new file mode 100644
index 0000000..d71646c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpscramble.h
@@ -0,0 +1,192 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Fixed window exponentiation scramble/unscramble
+//
+// Contents:
+// cpScramblePut()
+// cpScrambleGet()
+//
+//
+*/
+
+#if !defined(_PC_SCRAMBLE_H)
+#define _PC_SCRAMBLE_H
+
+/*
+// cpsScramblePut/cpsScrambleGet
+// stores to/retrieves from pScrambleEntry position
+// pre-computed data if fixed window method is used
+*/
+__INLINE void cpScramblePut(Ipp8u* pArray, cpSize colummSize,
+ const Ipp32u* pData, cpSize dataSize)
+{
+ int i;
+ switch(colummSize) {
+ case 1: // column - byte
+ dataSize *= sizeof(Ipp32u);
+ for(i=0; i<dataSize; i++)
+ pArray[i*CACHE_LINE_SIZE] = ((Ipp8u*)pData)[i];
+ break;
+ case 2: // column - word (2 bytes)
+ dataSize *= sizeof(Ipp16u);
+ for(i=0; i<dataSize; i++)
+ ((Ipp16u*)pArray)[i*CACHE_LINE_SIZE/sizeof(Ipp16u)] = ((Ipp16u*)pData)[i];
+ break;
+ case 4: // column - dword (4 bytes)
+ for(i=0; i<dataSize; i++)
+ ((Ipp32u*)pArray)[i*CACHE_LINE_SIZE/sizeof(Ipp32u)] = pData[i];
+ break;
+ case 8: // column - qword (8 bytes => 2 dword)
+ for(; dataSize>=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) {
+ ((Ipp32u*)pArray)[0] = pData[0];
+ ((Ipp32u*)pArray)[1] = pData[1];
+ }
+ if(dataSize)
+ ((Ipp32u*)pArray)[0] = pData[0];
+ break;
+ case 16: // column - oword (16 bytes => 4 dword)
+ for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) {
+ ((Ipp32u*)pArray)[0] = pData[0];
+ ((Ipp32u*)pArray)[1] = pData[1];
+ ((Ipp32u*)pArray)[2] = pData[2];
+ ((Ipp32u*)pArray)[3] = pData[3];
+ }
+ for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
+ ((Ipp32u*)pArray)[0] = pData[0];
+ break;
+ case 32: // column - 2 oword (32 bytes => 8 dword)
+ for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) {
+ ((Ipp32u*)pArray)[0] = pData[0];
+ ((Ipp32u*)pArray)[1] = pData[1];
+ ((Ipp32u*)pArray)[2] = pData[2];
+ ((Ipp32u*)pArray)[3] = pData[3];
+ ((Ipp32u*)pArray)[4] = pData[4];
+ ((Ipp32u*)pArray)[5] = pData[5];
+ ((Ipp32u*)pArray)[6] = pData[6];
+ ((Ipp32u*)pArray)[7] = pData[7];
+ }
+ for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
+ ((Ipp32u*)pArray)[0] = pData[0];
+ break;
+ default:
+ break;
+ }
+}
+
+
+/*
+// Retrieve data from pArray
+*/
+#define u8_to_u32(b0,b1,b2,b3, x) \
+ ((x) = (b0), \
+ (x)|=((b1)<<8), \
+ (x)|=((b2)<<16), \
+ (x)|=((b3)<<24))
+#define u16_to_u32(w0,w1, x) \
+ ((x) = (w0), \
+ (x)|=((w1)<<16))
+#define u32_to_u64(dw0,dw1, x) \
+ ((x) = (Ipp64u)(dw0), \
+ (x)|= (((Ipp64u)(dw1))<<32))
+
+__INLINE void cpScrambleGet(Ipp32u* pData, cpSize dataSize,
+ const Ipp8u* pArray, cpSize colummSize)
+{
+ int i;
+ switch(colummSize) {
+ case 1: // column - byte
+ for(i=0; i<dataSize; i++, pArray+=sizeof(Ipp32u)*CACHE_LINE_SIZE)
+ u8_to_u32(pArray[0*CACHE_LINE_SIZE], pArray[1*CACHE_LINE_SIZE], pArray[2*CACHE_LINE_SIZE], pArray[3*CACHE_LINE_SIZE], pData[i]);
+ break;
+ case 2: // column - word (2 bytes)
+ for(i=0; i<dataSize; i++, pArray+=sizeof(Ipp16u)*CACHE_LINE_SIZE) {
+ Ipp16u w0 = *((Ipp16u*)(pArray));
+ Ipp16u w1 = *((Ipp16u*)(pArray+CACHE_LINE_SIZE));
+ u16_to_u32( w0, w1, pData[i]);
+ }
+ break;
+ case 4: // column - dword (4 bytes)
+ for(i=0; i<dataSize; i++, pArray+=CACHE_LINE_SIZE)
+ pData[i] = ((Ipp32u*)pArray)[0];
+ break;
+ case 8: // column - qword (8 bytes => 2 dword)
+ for(; dataSize>=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) {
+ pData[0] = ((Ipp32u*)pArray)[0];
+ pData[1] = ((Ipp32u*)pArray)[1];
+ }
+ if(dataSize)
+ pData[0] = ((Ipp32u*)pArray)[0];
+ break;
+ case 16: // column - oword (16 bytes => 4 dword)
+ for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) {
+ pData[0] = ((Ipp32u*)pArray)[0];
+ pData[1] = ((Ipp32u*)pArray)[1];
+ pData[2] = ((Ipp32u*)pArray)[2];
+ pData[3] = ((Ipp32u*)pArray)[3];
+
+ }
+ for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
+ pData[0] = ((Ipp32u*)pArray)[0];
+ break;
+ case 32: // column - 2 oword (32 bytes => 8 dword)
+ for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) {
+ pData[0] = ((Ipp32u*)pArray)[0];
+ pData[1] = ((Ipp32u*)pArray)[1];
+ pData[2] = ((Ipp32u*)pArray)[2];
+ pData[3] = ((Ipp32u*)pArray)[3];
+ pData[4] = ((Ipp32u*)pArray)[4];
+ pData[5] = ((Ipp32u*)pArray)[5];
+ pData[6] = ((Ipp32u*)pArray)[6];
+ pData[7] = ((Ipp32u*)pArray)[7];
+ }
+ for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
+ pData[0] = ((Ipp32u*)pArray)[0];
+ break;
+ default:
+ break;
+ }
+}
+
+#endif /* _PC_SCRAMBLE_H */
diff --git a/ext/ipp/sources/ippcp/pcpsha1duplicate.c b/ext/ipp/sources/ippcp/pcpsha1duplicate.c
new file mode 100644
index 0000000..e7644dc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1duplicate.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Duplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA1Duplicate
+//
+// Purpose: Clone SHA1 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA1
+// pDstState->idCtx != idCtxSHA1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source SHA1 state
+// pDstState pointer to the target SHA1 state
+//
+// Note:
+// pDstState may to be uninitialized by ippsSHA1Init()
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Duplicate,(const IppsSHA1State* pSrcState, IppsSHA1State* pDstState))
+{
+ /* test state pointers */
+ IPP_BAD_PTR2_RET(pSrcState, pDstState);
+ pSrcState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pSrcState, SHA1_ALIGNMENT) );
+ pDstState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pDstState, SHA1_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA1 !=HASH_CTX_ID(pSrcState), ippStsContextMatchErr);
+
+ /* copy state */
+ CopyBlock(pSrcState, pDstState, sizeof(IppsSHA1State));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1final.c b/ext/ipp/sources/ippcp/pcpsha1final.c
new file mode 100644
index 0000000..32166b8
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1final.c
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Final()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsSHA1Final
+//
+// Purpose: Stop message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Final,(Ipp8u* pMD, IppsSHA1State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA1 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ cpFinalizeSHA1(HASH_VALUE(pState), HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(HASH_VALUE(pState)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(HASH_VALUE(pState)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(HASH_VALUE(pState)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(HASH_VALUE(pState)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(HASH_VALUE(pState)[4]);
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ sha1_hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1getsize.c b/ext/ipp/sources/ippcp/pcpsha1getsize.c
new file mode 100644
index 0000000..1fc50b5
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1getsize.c
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1GetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA1GetSize
+//
+// Purpose: Returns size (bytes) of IppsSHA1State state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1GetSize,(int* pSize))
+{
+ /* test pointer */
+ IPP_BAD_PTR1_RET(pSize);
+
+ *pSize = sizeof(IppsSHA1State) +(SHA1_ALIGNMENT-1);
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1gettag.c b/ext/ipp/sources/ippcp/pcpsha1gettag.c
new file mode 100644
index 0000000..4b7bb5a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1gettag.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1GetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsSHA1GetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA1
+// ippStsLengthErr max_SHA_digestLen < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHS state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA1State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA1 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA1)<tagLen), ippStsLengthErr);
+
+ {
+ DigestSHA1 digest;
+ CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA1));
+ cpFinalizeSHA1(digest, HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ digest[0] = ENDIANNESS32(digest[0]);
+ digest[1] = ENDIANNESS32(digest[1]);
+ digest[2] = ENDIANNESS32(digest[2]);
+ digest[3] = ENDIANNESS32(digest[3]);
+ digest[4] = ENDIANNESS32(digest[4]);
+ CopyBlock(digest, pTag, tagLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1init.c b/ext/ipp/sources/ippcp/pcpsha1init.c
new file mode 100644
index 0000000..2830ce0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1init.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsSHA1Init
+//
+// Purpose: Init SHA1 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA1 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Init,(IppsSHA1State* pState))
+{
+ /* test state pointer */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) );
+
+ PaddBlock(0, pState, sizeof(IppsSHA1State));
+ HASH_CTX_ID(pState) = idCtxSHA1;
+ sha1_hashInit(HASH_VALUE(pState));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1messagedigest.c b/ext/ipp/sources/ippcp/pcpsha1messagedigest.c
new file mode 100644
index 0000000..ec94ce9
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1messagedigest.c
@@ -0,0 +1,121 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsSHA1MessageDigest
+//
+// Purpose: Digest of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMsg == NULL
+// pMD == NULL
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+ /* test message length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((len && !pMsg), ippStsNullPtrErr);
+
+ {
+ /* select processing function */
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ cpHashProc updateFunc = UpdateSHA1ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ cpHashProc updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA1ni : UpdateSHA1;
+ #else
+ cpHashProc updateFunc = UpdateSHA1;
+ #endif
+
+ /* message length in the multiple MBS and the rest */
+ int msgLenBlks = len & (-MBS_SHA1);
+ int msgLenRest = len - msgLenBlks;
+
+ /* init hash */
+ ((Ipp32u*)(pMD))[0] = sha1_iv[0];
+ ((Ipp32u*)(pMD))[1] = sha1_iv[1];
+ ((Ipp32u*)(pMD))[2] = sha1_iv[2];
+ ((Ipp32u*)(pMD))[3] = sha1_iv[3];
+ ((Ipp32u*)(pMD))[4] = sha1_iv[4];
+
+ /* process main part of the message */
+ if(msgLenBlks) {
+ updateFunc((Ipp32u*)pMD, pMsg, msgLenBlks, sha1_cnt);
+ pMsg += msgLenBlks;
+ }
+
+ cpFinalizeSHA1((Ipp32u*)pMD, pMsg, msgLenRest, len);
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pMD)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pMD)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pMD)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pMD)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pMD)[4]);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1pack.c b/ext/ipp/sources/ippcp/pcpsha1pack.c
new file mode 100644
index 0000000..42bb007
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1pack.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Pack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA1Pack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pBuffer == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the hash state
+// pBuffer pointer to the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Pack,(const IppsSHA1State* pState, Ipp8u* pBuffer))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA1 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ CopyBlock(pState, pBuffer, sizeof(IppsSHA1State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1stuff.h b/ext/ipp/sources/ippcp/pcpsha1stuff.h
new file mode 100644
index 0000000..1d87fbc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1stuff.h
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// SHA1 stuff
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+#if !defined(_CP_HASH_SHA1)
+#define _CP_HASH_SHA1
+
+/* SHA-1 constants */
+static const Ipp32u sha1_iv[] = {
+ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};
+
+static __ALIGN16 const Ipp32u sha1_cnt[] = {
+ 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
+};
+
+static void sha1_hashInit(void* pHash)
+{
+ /* setup initial digest */
+ ((Ipp32u*)pHash)[0] = sha1_iv[0];
+ ((Ipp32u*)pHash)[1] = sha1_iv[1];
+ ((Ipp32u*)pHash)[2] = sha1_iv[2];
+ ((Ipp32u*)pHash)[3] = sha1_iv[3];
+ ((Ipp32u*)pHash)[4] = sha1_iv[4];
+}
+
+static void sha1_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSHA1(pHash, pMsg, msgLen, sha1_cnt);
+}
+
+#if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+static void sha1_ni_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSHA1ni(pHash, pMsg, msgLen, sha1_cnt);
+}
+#endif
+
+static void sha1_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
+}
+
+static void sha1_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
+{
+ UNREFERENCED_PARAMETER(lenHi);
+ lenLo = ENDIANNESS64(lenLo<<3);
+ ((Ipp64u*)(pDst))[0] = lenLo;
+}
+
+#define cpFinalizeSHA1 OWNAPI(cpFinalizeSHA1)
+void cpFinalizeSHA1(DigestSHA1 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen);
+
+#endif /* #if !defined(_CP_HASH_SHA1) */ \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpsha1unpack.c b/ext/ipp/sources/ippcp/pcpsha1unpack.c
new file mode 100644
index 0000000..5149cd0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1unpack.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Unpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA1Unpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the input buffer
+// pCtx pointer hash state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Unpack,(const Ipp8u* pBuffer, IppsSHA1State* pCtx))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pCtx, pBuffer);
+ pCtx = (IppsSHA1State*)( IPP_ALIGNED_PTR(pCtx, SHA1_ALIGNMENT) );
+
+ CopyBlock(pBuffer, pCtx, sizeof(IppsSHA1State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha1update.c b/ext/ipp/sources/ippcp/pcpsha1update.c
new file mode 100644
index 0000000..fb88797
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha1update.c
@@ -0,0 +1,146 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA1
+//
+// Contents:
+// ippsSHA1Update()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha1stuff.h"
+
+/*F*
+// Name: ippsSHA1Update
+//
+// Purpose: Updates intermediate digest based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrc == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA1
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the SHA1 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA1Update,(const Ipp8u* pSrc, int len, IppsSHA1State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA1 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test input length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test source pointer */
+ IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
+
+ /*
+ // handle non empty message
+ */
+ if(len) {
+ /* select processing function */
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ cpHashProc updateFunc = UpdateSHA1ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ cpHashProc updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA1ni : UpdateSHA1;
+ #else
+ cpHashProc updateFunc = UpdateSHA1;
+ #endif
+
+ int procLen;
+
+ int idx = HAHS_BUFFIDX(pState);
+ Ipp8u* pBuffer = HASH_BUFF(pState);
+ Ipp64u lenLo = HASH_LENLO(pState) +len;
+
+ /* if non empty internal buffer filling */
+ if(idx) {
+ /* copy from input stream to the internal buffer as match as possible */
+ procLen = IPP_MIN(len, (MBS_SHA1-idx));
+ CopyBlock(pSrc, pBuffer+idx, procLen);
+
+ /* update message pointer and length */
+ idx += procLen;
+ pSrc += procLen;
+ len -= procLen;
+
+ /* update digest if buffer full */
+ if( MBS_SHA1 == idx) {
+ updateFunc(HASH_VALUE(pState), pBuffer, MBS_SHA1, sha1_cnt);
+ idx = 0;
+ }
+ }
+
+ /* main message part processing */
+ procLen = len & ~(MBS_SHA1-1);
+ if(procLen) {
+ updateFunc(HASH_VALUE(pState), pSrc, procLen, sha1_cnt);
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* store rest of message into the internal buffer */
+ if(len) {
+ CopyBlock(pSrc, pBuffer, len);
+ idx += len;
+ }
+
+ /* update length of processed message */
+ HASH_LENLO(pState) = lenLo;
+ HAHS_BUFFIDX(pState) = idx;
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224duplicate.c b/ext/ipp/sources/ippcp/pcpsha224duplicate.c
new file mode 100644
index 0000000..eb74ca3
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224duplicate.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Duplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA224Duplicate
+//
+// Purpose: Clone SHA224 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA256
+// pDstState->idCtx != idCtxSHA256
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source SHA224 state
+// pDstState pointer to the target SHA224 state
+//
+// Note:
+// pDstState may to be uninitialized by ippsSHA224Init()
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcState, IppsSHA224State* pDstState))
+{
+ return ippsSHA256Duplicate(pSrcState, pDstState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224final.c b/ext/ipp/sources/ippcp/pcpsha224final.c
new file mode 100644
index 0000000..4e5760b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224final.c
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Final()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA224Final
+//
+// Purpose: Stop message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHA224 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ cpFinalizeSHA256(HASH_VALUE(pState), HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(HASH_VALUE(pState)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(HASH_VALUE(pState)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(HASH_VALUE(pState)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(HASH_VALUE(pState)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(HASH_VALUE(pState)[4]);
+ ((Ipp32u*)pMD)[5] = ENDIANNESS32(HASH_VALUE(pState)[5]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(HASH_VALUE(pState)[6]);
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ sha224_hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224getsize.c b/ext/ipp/sources/ippcp/pcpsha224getsize.c
new file mode 100644
index 0000000..ce1a584
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224getsize.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224GetSize()
+//
+*/
+
+/*F*
+// Name: ippsSHA224GetSize
+//
+// Purpose: Returns size (bytes) of IppsSHA224State state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+IPPFUN(IppStatus, ippsSHA224GetSize,(int* pSize))
+{
+ return GetSizeSHA256(pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224gettag.c b/ext/ipp/sources/ippcp/pcpsha224gettag.c
new file mode 100644
index 0000000..0c4c925
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224gettag.c
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224GetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA224GetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsLengthErr max_SHA_digestLen < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHA224 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA224State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA224)<tagLen), ippStsLengthErr);
+
+ {
+ DigestSHA256 digest;
+ CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA256));
+ cpFinalizeSHA256(digest, HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ digest[0] = ENDIANNESS32(digest[0]);
+ digest[1] = ENDIANNESS32(digest[1]);
+ digest[2] = ENDIANNESS32(digest[2]);
+ digest[3] = ENDIANNESS32(digest[3]);
+ digest[4] = ENDIANNESS32(digest[4]);
+ digest[5] = ENDIANNESS32(digest[5]);
+ digest[6] = ENDIANNESS32(digest[6]);
+ digest[7] = ENDIANNESS32(digest[7]);
+ CopyBlock(digest, pTag, tagLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224init.c b/ext/ipp/sources/ippcp/pcpsha224init.c
new file mode 100644
index 0000000..d862126
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224init.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA224Init
+//
+// Purpose: Init SHA224
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA224 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Init,(IppsSHA224State* pState))
+{
+ return InitSHA256(pState, sha224_iv);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224messagedigest.c b/ext/ipp/sources/ippcp/pcpsha224messagedigest.c
new file mode 100644
index 0000000..905581a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224messagedigest.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA224MessageDigest
+//
+// Purpose: Digest of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMsg == NULL
+// pMD == NULL
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ {
+ DigestSHA256 hash;
+ IppStatus sts = cpSHA256MessageDigest(hash, pMsg, len, sha224_iv);
+ if(ippStsNoErr==sts)
+ CopyBlock(hash, pMD, IPP_SHA224_DIGEST_BITSIZE/BYTESIZE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224pack.c b/ext/ipp/sources/ippcp/pcpsha224pack.c
new file mode 100644
index 0000000..85fe016
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224pack.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Pack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA224Pack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the hash state
+// pBuffer pointer to the destination buffer
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pState, Ipp8u* pBuffer))
+{
+ return ippsSHA256Pack(pState, pBuffer);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224unpack.c b/ext/ipp/sources/ippcp/pcpsha224unpack.c
new file mode 100644
index 0000000..53ba908
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224unpack.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Unpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA224Unpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the input buffer
+// pState pointer hash state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pState))
+{
+ return ippsSHA256Unpack(pBuffer, pState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha224update.c b/ext/ipp/sources/ippcp/pcpsha224update.c
new file mode 100644
index 0000000..aaa9e63
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha224update.c
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA224Update()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA224Update
+//
+// Purpose: Updates intermadiate digest based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrc == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the SHA224 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pState))
+{
+ return ippsSHA256Update(pSrc, len, pState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256_messagedigest.c b/ext/ipp/sources/ippcp/pcpsha256_messagedigest.c
new file mode 100644
index 0000000..6902f8c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256_messagedigest.c
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// cpSHA256MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+IppStatus cpSHA256MessageDigest(DigestSHA256 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA256 IV)
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(hash);
+ /* test message length */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ {
+ /* select processing function */
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ cpHashProc updateFunc = UpdateSHA256ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ cpHashProc updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA256ni : UpdateSHA256;
+ #else
+ cpHashProc updateFunc = UpdateSHA256;
+ #endif
+
+ /* message length in the multiple MBS and the rest */
+ int msgLenBlks = msgLen & (-MBS_SHA256);
+ int msgLenRest = msgLen % MBS_SHA256;
+
+ /* init hash */
+ hash[0] = IV[0];
+ hash[1] = IV[1];
+ hash[2] = IV[2];
+ hash[3] = IV[3];
+ hash[4] = IV[4];
+ hash[5] = IV[5];
+ hash[6] = IV[6];
+ hash[7] = IV[7];
+
+ /* process main part of the message */
+ if(msgLenBlks) {
+ updateFunc(hash, pMsg, msgLenBlks, sha256_cnt);
+ pMsg += msgLenBlks;
+ }
+
+ cpFinalizeSHA256(hash, pMsg, msgLenRest, msgLen);
+ hash[0] = ENDIANNESS32(hash[0]);
+ hash[1] = ENDIANNESS32(hash[1]);
+ hash[2] = ENDIANNESS32(hash[2]);
+ hash[3] = ENDIANNESS32(hash[3]);
+ hash[4] = ENDIANNESS32(hash[4]);
+ hash[5] = ENDIANNESS32(hash[5]);
+ hash[6] = ENDIANNESS32(hash[6]);
+ hash[7] = ENDIANNESS32(hash[7]);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256ca.c b/ext/ipp/sources/ippcp/pcpsha256ca.c
new file mode 100644
index 0000000..1d83767
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256ca.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// cpFinalizeSHA256()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+void cpFinalizeSHA256(DigestSHA256 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen)
+{
+ /* select processing function */
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ cpHashProc updateFunc = UpdateSHA256ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ cpHashProc updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA256ni : UpdateSHA256;
+ #else
+ cpHashProc updateFunc = UpdateSHA256;
+ #endif
+
+ /* local buffer and it length */
+ Ipp8u buffer[MBS_SHA256*2];
+ int bufferLen = inpLen < (MBS_SHA256-(int)MLR_SHA256)? MBS_SHA256 : MBS_SHA256*2;
+
+ /* copy rest of message into internal buffer */
+ CopyBlock(inpBuffer, buffer, inpLen);
+
+ /* padd message */
+ buffer[inpLen++] = 0x80;
+ PaddBlock(0, buffer+inpLen, bufferLen-inpLen-MLR_SHA256);
+
+ /* put processed message length in bits */
+ processedMsgLen = ENDIANNESS64(processedMsgLen<<3);
+ ((Ipp64u*)(buffer+bufferLen))[-1] = processedMsgLen;
+
+ /* copmplete hash computation */
+ updateFunc(pHash, buffer, bufferLen, sha256_cnt);
+} \ No newline at end of file
diff --git a/ext/ipp/sources/ippcp/pcpsha256duplicate.c b/ext/ipp/sources/ippcp/pcpsha256duplicate.c
new file mode 100644
index 0000000..46feae6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256duplicate.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Duplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA256Duplicate
+//
+// Purpose: Clone SHA256 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA256
+// pDstState->idCtx != idCtxSHA256
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source SHA256 state
+// pDstState pointer to the target SHA256 state
+//
+// Note:
+// pDstState may to be uninitialized by ippsSHA256Init()
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcState, IppsSHA256State* pDstState))
+{
+ /* test state pointers */
+ IPP_BAD_PTR2_RET(pSrcState, pDstState);
+ pSrcState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pSrcState, SHA256_ALIGNMENT) );
+ pDstState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pDstState, SHA256_ALIGNMENT) );
+ /* test states ID */
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pSrcState), ippStsContextMatchErr);
+
+ /* copy state */
+ CopyBlock(pSrcState, pDstState, sizeof(IppsSHA256State));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256final.c b/ext/ipp/sources/ippcp/pcpsha256final.c
new file mode 100644
index 0000000..2a8ca2f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256final.c
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Final()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+
+/*F*
+// Name: ippsSHA256Final
+//
+// Purpose: Stop message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHA256 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ cpFinalizeSHA256(HASH_VALUE(pState), HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(HASH_VALUE(pState)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(HASH_VALUE(pState)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(HASH_VALUE(pState)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(HASH_VALUE(pState)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(HASH_VALUE(pState)[4]);
+ ((Ipp32u*)pMD)[5] = ENDIANNESS32(HASH_VALUE(pState)[5]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(HASH_VALUE(pState)[6]);
+ ((Ipp32u*)pMD)[7] = ENDIANNESS32(HASH_VALUE(pState)[7]);
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ sha256_hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256getsize.c b/ext/ipp/sources/ippcp/pcpsha256getsize.c
new file mode 100644
index 0000000..7bdd216
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256getsize.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256GetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA256GetSize
+//
+// Purpose: Returns size (bytes) of IppsSHA256State state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256GetSize,(int* pSize))
+{
+ return GetSizeSHA256(pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256gettag.c b/ext/ipp/sources/ippcp/pcpsha256gettag.c
new file mode 100644
index 0000000..d68b2cb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256gettag.c
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256GetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA256GetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsLengthErr max_SHA_digestLen < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHA256 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA256)<tagLen), ippStsLengthErr);
+
+ {
+ DigestSHA256 digest;
+ CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA256));
+ cpFinalizeSHA256(digest, HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
+ digest[0] = ENDIANNESS32(digest[0]);
+ digest[1] = ENDIANNESS32(digest[1]);
+ digest[2] = ENDIANNESS32(digest[2]);
+ digest[3] = ENDIANNESS32(digest[3]);
+ digest[4] = ENDIANNESS32(digest[4]);
+ digest[5] = ENDIANNESS32(digest[5]);
+ digest[6] = ENDIANNESS32(digest[6]);
+ digest[7] = ENDIANNESS32(digest[7]);
+ CopyBlock(digest, pTag, tagLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256init.c b/ext/ipp/sources/ippcp/pcpsha256init.c
new file mode 100644
index 0000000..11d60ae
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256init.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA256Init
+//
+// Purpose: Init SHA256
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA256 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Init,(IppsSHA256State* pState))
+{
+ return InitSHA256(pState, sha256_iv);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256messagedigest.c b/ext/ipp/sources/ippcp/pcpsha256messagedigest.c
new file mode 100644
index 0000000..bceea7c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256messagedigest.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA256MessageDigest
+//
+// Purpose: Digest of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMsg == NULL
+// pMD == NULL
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ {
+ DigestSHA256 hash;
+ IppStatus sts = cpSHA256MessageDigest(hash, pMsg, len, sha256_iv);
+ if(ippStsNoErr==sts)
+ CopyBlock(hash, pMD, IPP_SHA256_DIGEST_BITSIZE/BYTESIZE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256pack.c b/ext/ipp/sources/ippcp/pcpsha256pack.c
new file mode 100644
index 0000000..c734b6b
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256pack.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Pack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA256Pack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the hash state
+// pBuffer pointer to the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pState, Ipp8u* pBuffer))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ CopyBlock(pState, pBuffer, sizeof(IppsSHA256State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256stuff.h b/ext/ipp/sources/ippcp/pcpsha256stuff.h
new file mode 100644
index 0000000..3a4a8fc
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256stuff.h
@@ -0,0 +1,200 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256GetSize()
+// ippsSHA256Init()
+// ippsSHA256Pack()
+// ippsSHA256Unpack()
+// ippsSHA256Duplicate()
+// ippsSHA256Update()
+// ippsSHA256GetTag()
+// ippsSHA256Final()
+// ippsSHA256MessageDigest()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+
+#if !defined(_PCP_SHA256_STUFF_H)
+#define _PCP_SHA256_STUFF_H
+
+/* SHA-256, SHA-224 constants */
+static const Ipp32u sha256_iv[] = {
+ 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
+ 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19};
+static const Ipp32u sha224_iv[] = {
+ 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939,
+ 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4};
+
+static __ALIGN16 const Ipp32u sha256_cnt[] = {
+ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
+ 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
+ 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
+ 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
+ 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
+ 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
+ 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
+ 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
+ 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
+ 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
+ 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
+ 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
+ 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
+ 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
+ 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
+ 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
+};
+
+
+/* setup init hash value */
+__INLINE void hashInit(Ipp32u* pHash, const Ipp32u* iv)
+{
+ pHash[0] = iv[0];
+ pHash[1] = iv[1];
+ pHash[2] = iv[2];
+ pHash[3] = iv[3];
+ pHash[4] = iv[4];
+ pHash[5] = iv[5];
+ pHash[6] = iv[6];
+ pHash[7] = iv[7];
+}
+static void sha256_hashInit(void* pHash)
+{
+ hashInit((Ipp32u*)pHash, sha256_iv);
+}
+static void sha224_hashInit(void* pHash)
+{
+ hashInit((Ipp32u*)pHash, sha224_iv);
+}
+
+static void sha256_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSHA256(pHash, pMsg, msgLen, sha256_cnt);
+}
+#if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
+static void sha256_ni_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSHA256ni(pHash, pMsg, msgLen, sha256_cnt);
+}
+#endif
+
+/* convert hash into big endian */
+static void sha256_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
+ ((Ipp32u*)pMD)[5] = ENDIANNESS32(((Ipp32u*)pHashVal)[5]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[6]);
+ ((Ipp32u*)pMD)[7] = ENDIANNESS32(((Ipp32u*)pHashVal)[7]);
+}
+static void sha224_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
+ ((Ipp32u*)pMD)[5] = ENDIANNESS32(((Ipp32u*)pHashVal)[5]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[6]);
+}
+
+static void sha256_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
+{
+ UNREFERENCED_PARAMETER(lenHi);
+ lenLo = ENDIANNESS64(lenLo<<3);
+ ((Ipp64u*)(pDst))[0] = lenLo;
+}
+
+/*
+// SHA256 init context
+*/
+static IppStatus GetSizeSHA256(int* pSize)
+{
+ IPP_BAD_PTR1_RET(pSize);
+ *pSize = sizeof(IppsSHA256State) +(SHA256_ALIGNMENT-1);
+ return ippStsNoErr;
+}
+
+static IppStatus InitSHA256(IppsSHA256State* pState, const DigestSHA256 IV)
+{
+ /* test state pointer */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+
+ HASH_CTX_ID(pState) = idCtxSHA256;
+ HASH_LENLO(pState) = 0;
+ HAHS_BUFFIDX(pState) = 0;
+
+ /* setup initial digest */
+ HASH_VALUE(pState)[0] = IV[0];
+ HASH_VALUE(pState)[1] = IV[1];
+ HASH_VALUE(pState)[2] = IV[2];
+ HASH_VALUE(pState)[3] = IV[3];
+ HASH_VALUE(pState)[4] = IV[4];
+ HASH_VALUE(pState)[5] = IV[5];
+ HASH_VALUE(pState)[6] = IV[6];
+ HASH_VALUE(pState)[7] = IV[7];
+
+ return ippStsNoErr;
+}
+
+#define cpSHA256MessageDigest OWNAPI(cpSHA256MessageDigest)
+IppStatus cpSHA256MessageDigest(DigestSHA256 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA256 IV);
+
+#define cpFinalizeSHA256 OWNAPI(cpFinalizeSHA256)
+void cpFinalizeSHA256(DigestSHA256 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen);
+
+#endif /* #if !defined(_PCP_SHA256_STUFF_H) */
diff --git a/ext/ipp/sources/ippcp/pcpsha256unpack.c b/ext/ipp/sources/ippcp/pcpsha256unpack.c
new file mode 100644
index 0000000..e907f16
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256unpack.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Unpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA256Unpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the input buffer
+// pState pointer hash state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pState))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+
+ CopyBlock(pBuffer, pState, sizeof(IppsSHA256State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha256update.c b/ext/ipp/sources/ippcp/pcpsha256update.c
new file mode 100644
index 0000000..dd028b0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha256update.c
@@ -0,0 +1,146 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SHA256
+//
+// Contents:
+// ippsSHA256Update()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha256stuff.h"
+
+/*F*
+// Name: ippsSHA256Update
+//
+// Purpose: Updates intermadiate digest based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrc == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA256
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the SHA256 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test input length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test source pointer */
+ IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
+
+ /*
+ // handle non empty message
+ */
+ if(len) {
+ /* select processing function */
+ #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
+ cpHashProc updateFunc = UpdateSHA256ni;
+ #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
+ cpHashProc updateFunc = IsFeatureEnabled(ippCPUID_SHA)? UpdateSHA256ni : UpdateSHA256;
+ #else
+ cpHashProc updateFunc = UpdateSHA256;
+ #endif
+
+ int procLen;
+
+ int idx = HAHS_BUFFIDX(pState);
+ Ipp8u* pBuffer = HASH_BUFF(pState);
+ Ipp64u lenLo = HASH_LENLO(pState) +len;
+
+ /* if non empty internal buffer filling */
+ if(idx) {
+ /* copy from input stream to the internal buffer as match as possible */
+ procLen = IPP_MIN(len, (MBS_SHA256-idx));
+ CopyBlock(pSrc, pBuffer+idx, procLen);
+
+ /* update message pointer and length */
+ pSrc += procLen;
+ len -= procLen;
+ idx += procLen;
+
+ /* update digest if buffer full */
+ if( MBS_SHA256 == idx) {
+ updateFunc(HASH_VALUE(pState), pBuffer, MBS_SHA256, sha256_cnt);
+ idx = 0;
+ }
+ }
+
+ /* main message part processing */
+ procLen = len & ~(MBS_SHA256-1);
+ if(procLen) {
+ updateFunc(HASH_VALUE(pState), pSrc, procLen, sha256_cnt);
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* store rest of message into the internal buffer */
+ if(len) {
+ CopyBlock(pSrc, pBuffer, len);
+ idx += len;
+ }
+
+ /* update length of processed message */
+ HASH_LENLO(pState) = lenLo;
+ HAHS_BUFFIDX(pState) = idx;
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384duplicate.c b/ext/ipp/sources/ippcp/pcpsha384duplicate.c
new file mode 100644
index 0000000..e28b751
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384duplicate.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Duplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA384Duplicate
+//
+// Purpose: Clone SHA512 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA512
+// pDstState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source SHA384 state
+// pDstState pointer to the target SHA384 state
+// Note:
+// pDstState may to be uninitialized by ippsSHA384Init()
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384Duplicate,(const IppsSHA384State* pSrcState, IppsSHA384State* pDstState))
+{
+ return ippsSHA512Duplicate(pSrcState, pDstState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384final.c b/ext/ipp/sources/ippcp/pcpsha384final.c
new file mode 100644
index 0000000..1e38df6
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384final.c
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Final()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA384Final
+//
+// Purpose: Stop message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHA384 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384Final,(Ipp8u* pMD, IppsSHA384State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ cpFinalizeSHA512(HASH_VALUE(pState),
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState));
+ /* convert hash into big endian */
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(HASH_VALUE(pState)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(HASH_VALUE(pState)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(HASH_VALUE(pState)[2]);
+ ((Ipp64u*)pMD)[3] = ENDIANNESS64(HASH_VALUE(pState)[3]);
+ ((Ipp64u*)pMD)[4] = ENDIANNESS64(HASH_VALUE(pState)[4]);
+ ((Ipp64u*)pMD)[5] = ENDIANNESS64(HASH_VALUE(pState)[5]);
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ HASH_LENHI(pState) = 0;
+ sha512_384_hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384getsize.c b/ext/ipp/sources/ippcp/pcpsha384getsize.c
new file mode 100644
index 0000000..350950f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384getsize.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384GetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA384GetSize
+//
+// Purpose: Returns size (bytes) of IppsSHA384State state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384GetSize,(int* pSize))
+{
+ return GetSizeSHA512(pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384gettag.c b/ext/ipp/sources/ippcp/pcpsha384gettag.c
new file mode 100644
index 0000000..1c001cb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384gettag.c
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384GetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA384GetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsLengthErr max_SHA_digestLen < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHA384 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA384State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA384)<tagLen), ippStsLengthErr);
+
+ {
+ DigestSHA512 digest;
+ CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA512));
+ cpFinalizeSHA512(digest,
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState));
+ digest[0] = ENDIANNESS64(digest[0]);
+ digest[1] = ENDIANNESS64(digest[1]);
+ digest[2] = ENDIANNESS64(digest[2]);
+ digest[3] = ENDIANNESS64(digest[3]);
+ digest[4] = ENDIANNESS64(digest[4]);
+ digest[5] = ENDIANNESS64(digest[5]);
+ CopyBlock(digest, pTag, tagLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384init.c b/ext/ipp/sources/ippcp/pcpsha384init.c
new file mode 100644
index 0000000..f6618c7
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384init.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA384Init
+//
+// Purpose: Init SHA384
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA384 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384Init,(IppsSHA384State* pState))
+{
+ return InitSHA512(pState, sha512_384_iv);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384messagedigest.c b/ext/ipp/sources/ippcp/pcpsha384messagedigest.c
new file mode 100644
index 0000000..0463fa0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384messagedigest.c
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA384MessageDigest
+//
+// Purpose: Digest of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMsg == NULL
+// pMD == NULL
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ {
+ DigestSHA512 hash;
+ IppStatus sts = cpSHA512MessageDigest(hash, pMsg, len, sha512_384_iv);
+ if(ippStsNoErr==sts)
+ CopyBlock(hash, pMD, IPP_SHA384_DIGEST_BITSIZE/BYTESIZE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384pack.c b/ext/ipp/sources/ippcp/pcpsha384pack.c
new file mode 100644
index 0000000..542386a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384pack.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Pack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA384Pack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer hash state
+// pBuffer pointer to the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA384Pack,(const IppsSHA384State* pState, Ipp8u* pBuffer))
+{
+ return ippsSHA512Pack(pState, pBuffer);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384unpack.c b/ext/ipp/sources/ippcp/pcpsha384unpack.c
new file mode 100644
index 0000000..58d9165
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384unpack.c
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Unpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA384Unpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer== NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the input buffer
+// pState pointer hash state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384Unpack,(const Ipp8u* pBuffer, IppsSHA384State* pState))
+{
+ return ippsSHA512Unpack(pBuffer, pState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha384update.c b/ext/ipp/sources/ippcp/pcpsha384update.c
new file mode 100644
index 0000000..62610ba
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha384update.c
@@ -0,0 +1,80 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA384Update()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA384Update
+//
+// Purpose: Updates intermadiate digest based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrc == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the SHA384 state
+//
+*F*/
+
+IPPFUN(IppStatus, ippsSHA384Update,(const Ipp8u* pSrc, int len, IppsSHA384State* pState))
+{
+ return ippsSHA512Update(pSrc, len, pState);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512_init.c b/ext/ipp/sources/ippcp/pcpsha512_init.c
new file mode 100644
index 0000000..9dfcc3a
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512_init.c
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// InitSHA512()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+IppStatus InitSHA512(IppsSHA512State* pState, const DigestSHA512 IV)
+{
+ /* test state pointer */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+
+ /* set state ID */
+ HASH_CTX_ID(pState) = idCtxSHA512;
+ /* zeros message length */
+ HASH_LENLO(pState) = 0;
+ HASH_LENHI(pState) = 0;
+ /* message buffer is free */
+ HAHS_BUFFIDX(pState) = 0;
+ /* setup initial digest */
+ hashInit(HASH_VALUE(pState), IV);
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512_messagedigest.c b/ext/ipp/sources/ippcp/pcpsha512_messagedigest.c
new file mode 100644
index 0000000..0d2b14d
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512_messagedigest.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// cpSHA512MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+IppStatus cpSHA512MessageDigest(DigestSHA512 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA512 IV)
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(hash);
+ /* test message length */
+ IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
+ /* test message pointer */
+ IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
+
+ {
+ /* message length in the multiple MBS and the rest */
+ int msgLenBlks = msgLen & (-MBS_SHA512);
+ int msgLenRest = msgLen - msgLenBlks;
+
+ /* init hash */
+ hashInit(hash, IV);
+
+ /* process main part of the message */
+ if(msgLenBlks) {
+ UpdateSHA512(hash, pMsg, msgLenBlks, sha512_cnt);
+ pMsg += msgLenBlks;
+ }
+
+ cpFinalizeSHA512(hash, pMsg, msgLenRest, msgLen, 0);
+ hash[0] = ENDIANNESS64(hash[0]);
+ hash[1] = ENDIANNESS64(hash[1]);
+ hash[2] = ENDIANNESS64(hash[2]);
+ hash[3] = ENDIANNESS64(hash[3]);
+ hash[4] = ENDIANNESS64(hash[4]);
+ hash[5] = ENDIANNESS64(hash[5]);
+ hash[6] = ENDIANNESS64(hash[6]);
+ hash[7] = ENDIANNESS64(hash[7]);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512duplicate.c b/ext/ipp/sources/ippcp/pcpsha512duplicate.c
new file mode 100644
index 0000000..d169c76
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512duplicate.c
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Duplicate()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA512Duplicate
+//
+// Purpose: Clone SHA512 state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrcState == NULL
+// pDstState == NULL
+// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA512
+// pDstState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrcState pointer to the source SHA512 state
+// pDstState pointer to the target SHA512 state
+// Note:
+// pDstState may to be uninitialized by ippsSHA512Init()
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Duplicate,(const IppsSHA512State* pSrcState, IppsSHA512State* pDstState))
+{
+ /* test state pointers */
+ IPP_BAD_PTR2_RET(pSrcState, pDstState);
+ /* use aligned context */
+ pSrcState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pSrcState, SHA512_ALIGNMENT) );
+ pDstState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pDstState, SHA512_ALIGNMENT) );
+ /* test states ID */
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pSrcState), ippStsContextMatchErr);
+
+ /* copy state */
+ CopyBlock(pSrcState, pDstState, sizeof(IppsSHA512State));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512final.c b/ext/ipp/sources/ippcp/pcpsha512final.c
new file mode 100644
index 0000000..5cccaea
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512final.c
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Final()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512Final
+//
+// Purpose: Stop message digesting and return digest.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMD == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMD address of the output digest
+// pState pointer to the SHA512 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Final,(Ipp8u* pMD, IppsSHA512State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ cpFinalizeSHA512(HASH_VALUE(pState),
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState));
+ /* convert hash into big endian */
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(HASH_VALUE(pState)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(HASH_VALUE(pState)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(HASH_VALUE(pState)[2]);
+ ((Ipp64u*)pMD)[3] = ENDIANNESS64(HASH_VALUE(pState)[3]);
+ ((Ipp64u*)pMD)[4] = ENDIANNESS64(HASH_VALUE(pState)[4]);
+ ((Ipp64u*)pMD)[5] = ENDIANNESS64(HASH_VALUE(pState)[5]);
+ ((Ipp64u*)pMD)[6] = ENDIANNESS64(HASH_VALUE(pState)[6]);
+ ((Ipp64u*)pMD)[7] = ENDIANNESS64(HASH_VALUE(pState)[7]);
+
+ /* re-init hash value */
+ HAHS_BUFFIDX(pState) = 0;
+ HASH_LENLO(pState) = 0;
+ HASH_LENHI(pState) = 0;
+ sha512_hashInit(HASH_VALUE(pState));
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512getsize.c b/ext/ipp/sources/ippcp/pcpsha512getsize.c
new file mode 100644
index 0000000..2a1d1c1
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512getsize.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512GetSize()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512GetSize
+//
+// Purpose: Returns size (bytes) of IppsSHA512State state.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSize == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSize pointer to state size
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512GetSize,(int* pSize))
+{
+ return GetSizeSHA512(pSize);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512gettag.c b/ext/ipp/sources/ippcp/pcpsha512gettag.c
new file mode 100644
index 0000000..2fcbe53
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512gettag.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512GetTag()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512GetTag
+//
+// Purpose: Compute digest based on current state.
+// Note, that futher digest update is possible
+//
+// Returns: Reason:
+// ippStsNullPtrErr pTag == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsLengthErr max_SHA_digestLen < tagLen <1
+// ippStsNoErr no errors
+//
+// Parameters:
+// pTag address of the output digest
+// tagLen length of digest
+// pState pointer to the SHA512 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA512State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pTag);
+ IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA512)<tagLen), ippStsLengthErr);
+
+ {
+ DigestSHA512 digest;
+ CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA512));
+ cpFinalizeSHA512(digest,
+ HASH_BUFF(pState), HAHS_BUFFIDX(pState),
+ HASH_LENLO(pState), HASH_LENHI(pState));
+ digest[0] = ENDIANNESS64(digest[0]);
+ digest[1] = ENDIANNESS64(digest[1]);
+ digest[2] = ENDIANNESS64(digest[2]);
+ digest[3] = ENDIANNESS64(digest[3]);
+ digest[4] = ENDIANNESS64(digest[4]);
+ digest[5] = ENDIANNESS64(digest[5]);
+ digest[6] = ENDIANNESS64(digest[6]);
+ digest[7] = ENDIANNESS64(digest[7]);
+ CopyBlock(digest, pTag, tagLen);
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512init.c b/ext/ipp/sources/ippcp/pcpsha512init.c
new file mode 100644
index 0000000..b8cb6ba
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512init.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Init()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512Init
+//
+// Purpose: Init SHA512
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer to the SHA512 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Init,(IppsSHA512State* pState))
+{
+ return InitSHA512(pState, sha512_iv);
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512messagedigest.c b/ext/ipp/sources/ippcp/pcpsha512messagedigest.c
new file mode 100644
index 0000000..9076b94
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512messagedigest.c
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512MessageDigest()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512MessageDigest
+//
+// Purpose: Digest of the whole message.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMsg == NULL
+// pMD == NULL
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pMsg pointer to the input message
+// len input message length
+// pMD address of the output digest
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD))
+{
+ /* test digest pointer */
+ IPP_BAD_PTR1_RET(pMD);
+
+ {
+ DigestSHA512 hash;
+ IppStatus sts = cpSHA512MessageDigest(hash, pMsg, len, sha512_iv);
+ if(ippStsNoErr==sts)
+ CopyBlock(hash, pMD, IPP_SHA512_DIGEST_BITSIZE/BYTESIZE);
+ return sts;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512pack.c b/ext/ipp/sources/ippcp/pcpsha512pack.c
new file mode 100644
index 0000000..f9d8d04
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512pack.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Pack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA512Pack
+//
+// Purpose: Copy initialized context to the buffer.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsNoErr no errors
+//
+// Parameters:
+// pState pointer hash state
+// pBuffer pointer to the destination buffer
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Pack,(const IppsSHA512State* pState, Ipp8u* pBuffer))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ CopyBlock(pState, pBuffer, sizeof(IppsSHA512State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512stuff.h b/ext/ipp/sources/ippcp/pcpsha512stuff.h
new file mode 100644
index 0000000..6145854
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512stuff.h
@@ -0,0 +1,225 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// SHA512 stuff
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+#if !defined(_PCP_SHA512_STUFF_H)
+#define _PCP_SHA512_STUFF_H
+
+/* SHA-512, SHA-384, SHA512-224, SHA512 constants */
+static const Ipp64u sha512_iv[] = {
+ CONST_64(0x6A09E667F3BCC908), CONST_64(0xBB67AE8584CAA73B),
+ CONST_64(0x3C6EF372FE94F82B), CONST_64(0xA54FF53A5F1D36F1),
+ CONST_64(0x510E527FADE682D1), CONST_64(0x9B05688C2B3E6C1F),
+ CONST_64(0x1F83D9ABFB41BD6B), CONST_64(0x5BE0CD19137E2179)};
+static const Ipp64u sha512_384_iv[] = {
+ CONST_64(0xCBBB9D5DC1059ED8), CONST_64(0x629A292A367CD507),
+ CONST_64(0x9159015A3070DD17), CONST_64(0x152FECD8F70E5939),
+ CONST_64(0x67332667FFC00B31), CONST_64(0x8EB44A8768581511),
+ CONST_64(0xDB0C2E0D64F98FA7), CONST_64(0x47B5481DBEFA4FA4)};
+static const Ipp64u sha512_256_iv[] = {
+ CONST_64(0x22312194FC2BF72C), CONST_64(0x9F555FA3C84C64C2),
+ CONST_64(0x2393B86B6F53B151), CONST_64(0x963877195940EABD),
+ CONST_64(0x96283EE2A88EFFE3), CONST_64(0xBE5E1E2553863992),
+ CONST_64(0x2B0199FC2C85B8AA), CONST_64(0x0EB72DDC81C52CA2)};
+static const Ipp64u sha512_224_iv[] = {
+ CONST_64(0x8C3D37C819544DA2), CONST_64(0x73E1996689DCD4D6),
+ CONST_64(0x1DFAB7AE32FF9C82), CONST_64(0x679DD514582F9FCF),
+ CONST_64(0x0F6D2B697BD44DA8), CONST_64(0x77E36F7304C48942),
+ CONST_64(0x3F9D85A86A1D36C8), CONST_64(0x1112E6AD91D692A1)};
+
+static __ALIGN16 const Ipp64u sha512_cnt[] = {
+ CONST_64(0x428A2F98D728AE22), CONST_64(0x7137449123EF65CD), CONST_64(0xB5C0FBCFEC4D3B2F), CONST_64(0xE9B5DBA58189DBBC),
+ CONST_64(0x3956C25BF348B538), CONST_64(0x59F111F1B605D019), CONST_64(0x923F82A4AF194F9B), CONST_64(0xAB1C5ED5DA6D8118),
+ CONST_64(0xD807AA98A3030242), CONST_64(0x12835B0145706FBE), CONST_64(0x243185BE4EE4B28C), CONST_64(0x550C7DC3D5FFB4E2),
+ CONST_64(0x72BE5D74F27B896F), CONST_64(0x80DEB1FE3B1696B1), CONST_64(0x9BDC06A725C71235), CONST_64(0xC19BF174CF692694),
+ CONST_64(0xE49B69C19EF14AD2), CONST_64(0xEFBE4786384F25E3), CONST_64(0x0FC19DC68B8CD5B5), CONST_64(0x240CA1CC77AC9C65),
+ CONST_64(0x2DE92C6F592B0275), CONST_64(0x4A7484AA6EA6E483), CONST_64(0x5CB0A9DCBD41FBD4), CONST_64(0x76F988DA831153B5),
+ CONST_64(0x983E5152EE66DFAB), CONST_64(0xA831C66D2DB43210), CONST_64(0xB00327C898FB213F), CONST_64(0xBF597FC7BEEF0EE4),
+ CONST_64(0xC6E00BF33DA88FC2), CONST_64(0xD5A79147930AA725), CONST_64(0x06CA6351E003826F), CONST_64(0x142929670A0E6E70),
+ CONST_64(0x27B70A8546D22FFC), CONST_64(0x2E1B21385C26C926), CONST_64(0x4D2C6DFC5AC42AED), CONST_64(0x53380D139D95B3DF),
+ CONST_64(0x650A73548BAF63DE), CONST_64(0x766A0ABB3C77B2A8), CONST_64(0x81C2C92E47EDAEE6), CONST_64(0x92722C851482353B),
+ CONST_64(0xA2BFE8A14CF10364), CONST_64(0xA81A664BBC423001), CONST_64(0xC24B8B70D0F89791), CONST_64(0xC76C51A30654BE30),
+ CONST_64(0xD192E819D6EF5218), CONST_64(0xD69906245565A910), CONST_64(0xF40E35855771202A), CONST_64(0x106AA07032BBD1B8),
+ CONST_64(0x19A4C116B8D2D0C8), CONST_64(0x1E376C085141AB53), CONST_64(0x2748774CDF8EEB99), CONST_64(0x34B0BCB5E19B48A8),
+ CONST_64(0x391C0CB3C5C95A63), CONST_64(0x4ED8AA4AE3418ACB), CONST_64(0x5B9CCA4F7763E373), CONST_64(0x682E6FF3D6B2B8A3),
+ CONST_64(0x748F82EE5DEFB2FC), CONST_64(0x78A5636F43172F60), CONST_64(0x84C87814A1F0AB72), CONST_64(0x8CC702081A6439EC),
+ CONST_64(0x90BEFFFA23631E28), CONST_64(0xA4506CEBDE82BDE9), CONST_64(0xBEF9A3F7B2C67915), CONST_64(0xC67178F2E372532B),
+ CONST_64(0xCA273ECEEA26619C), CONST_64(0xD186B8C721C0C207), CONST_64(0xEADA7DD6CDE0EB1E), CONST_64(0xF57D4F7FEE6ED178),
+ CONST_64(0x06F067AA72176FBA), CONST_64(0x0A637DC5A2C898A6), CONST_64(0x113F9804BEF90DAE), CONST_64(0x1B710B35131C471B),
+ CONST_64(0x28DB77F523047D84), CONST_64(0x32CAAB7B40C72493), CONST_64(0x3C9EBE0A15C9BEBC), CONST_64(0x431D67C49C100D4C),
+ CONST_64(0x4CC5D4BECB3E42B6), CONST_64(0x597F299CFC657E2A), CONST_64(0x5FCB6FAB3AD6FAEC), CONST_64(0x6C44198C4A475817)
+};
+
+/* setup init hash value */
+__INLINE void hashInit(Ipp64u* pHash, const Ipp64u* iv)
+{
+ pHash[0] = iv[0];
+ pHash[1] = iv[1];
+ pHash[2] = iv[2];
+ pHash[3] = iv[3];
+ pHash[4] = iv[4];
+ pHash[5] = iv[5];
+ pHash[6] = iv[6];
+ pHash[7] = iv[7];
+}
+static void sha512_hashInit(void* pHash)
+{
+ hashInit((Ipp64u*)pHash, sha512_iv);
+}
+static void sha512_384_hashInit(void* pHash)
+{
+ hashInit((Ipp64u*)pHash, sha512_384_iv);
+}
+static void sha512_256_hashInit(void* pHash)
+{
+ hashInit((Ipp64u*)pHash, sha512_256_iv);
+}
+static void sha512_224_hashInit(void* pHash)
+{
+ hashInit((Ipp64u*)pHash, sha512_224_iv);
+}
+
+static void sha512_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSHA512(pHash, pMsg, msgLen, sha512_cnt);
+}
+
+/* convert hash into big endian */
+static void sha512_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(((Ipp64u*)pHashVal)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(((Ipp64u*)pHashVal)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(((Ipp64u*)pHashVal)[2]);
+ ((Ipp64u*)pMD)[3] = ENDIANNESS64(((Ipp64u*)pHashVal)[3]);
+ ((Ipp64u*)pMD)[4] = ENDIANNESS64(((Ipp64u*)pHashVal)[4]);
+ ((Ipp64u*)pMD)[5] = ENDIANNESS64(((Ipp64u*)pHashVal)[5]);
+ ((Ipp64u*)pMD)[6] = ENDIANNESS64(((Ipp64u*)pHashVal)[6]);
+ ((Ipp64u*)pMD)[7] = ENDIANNESS64(((Ipp64u*)pHashVal)[7]);
+}
+static void sha512_384_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(((Ipp64u*)pHashVal)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(((Ipp64u*)pHashVal)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(((Ipp64u*)pHashVal)[2]);
+ ((Ipp64u*)pMD)[3] = ENDIANNESS64(((Ipp64u*)pHashVal)[3]);
+ ((Ipp64u*)pMD)[4] = ENDIANNESS64(((Ipp64u*)pHashVal)[4]);
+ ((Ipp64u*)pMD)[5] = ENDIANNESS64(((Ipp64u*)pHashVal)[5]);
+}
+static void sha512_256_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(((Ipp64u*)pHashVal)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(((Ipp64u*)pHashVal)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(((Ipp64u*)pHashVal)[2]);
+ ((Ipp64u*)pMD)[3] = ENDIANNESS64(((Ipp64u*)pHashVal)[3]);
+}
+static void sha512_224_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ ((Ipp64u*)pMD)[0] = ENDIANNESS64(((Ipp64u*)pHashVal)[0]);
+ ((Ipp64u*)pMD)[1] = ENDIANNESS64(((Ipp64u*)pHashVal)[1]);
+ ((Ipp64u*)pMD)[2] = ENDIANNESS64(((Ipp64u*)pHashVal)[2]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[7]);
+}
+
+static void sha512_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
+{
+ lenHi = LSL64(lenHi,3) | LSR64(lenLo,63-3);
+ lenLo = LSL64(lenLo,3);
+ ((Ipp64u*)(pDst))[0] = ENDIANNESS64(lenHi);
+ ((Ipp64u*)(pDst))[1] = ENDIANNESS64(lenLo);
+}
+
+static IppStatus GetSizeSHA512(int* pSize)
+{
+ /* test pointer */
+ IPP_BAD_PTR1_RET(pSize);
+ *pSize = sizeof(IppsSHA512State) +(SHA512_ALIGNMENT-1);
+ return ippStsNoErr;
+}
+
+//#define cpFinalizeSHA512 OWNAPI(cpFinalizeSHA512)
+//void cpFinalizeSHA512(DigestSHA512 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u lenLo, Ipp64u lenHi);
+#define cpSHA512MessageDigest OWNAPI(cpSHA512MessageDigest)
+IppStatus cpSHA512MessageDigest(DigestSHA512 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA512 IV);
+#define InitSHA512 OWNAPI(InitSHA512)
+IppStatus InitSHA512(IppsSHA512State* pState, const DigestSHA512 IV);
+
+static void cpFinalizeSHA512(DigestSHA512 pHash,
+ const Ipp8u* inpBuffer, int inpLen,
+ Ipp64u lenLo, Ipp64u lenHi)
+{
+ /* local buffer and it length */
+ Ipp8u buffer[MBS_SHA512*2];
+ int bufferLen = inpLen < (MBS_SHA512-(int)MLR_SHA512)? MBS_SHA512 : MBS_SHA512*2;
+
+ /* copy rest of message into internal buffer */
+ CopyBlock(inpBuffer, buffer, inpLen);
+
+ /* padd message */
+ buffer[inpLen++] = 0x80;
+ PaddBlock(0, buffer+inpLen, bufferLen-inpLen-MLR_SHA512);
+
+ /* message length representation */
+ lenHi = LSL64(lenHi,3) | LSR64(lenLo,63-3);
+ lenLo = LSL64(lenLo,3);
+ ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(lenHi);
+ ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lenLo);
+
+ /* copmplete hash computation */
+ UpdateSHA512(pHash, buffer, bufferLen, sha512_cnt);
+}
+
+#endif /* #if !defined(_PCP_SHA512_STUFF_H) */
diff --git a/ext/ipp/sources/ippcp/pcpsha512unpack.c b/ext/ipp/sources/ippcp/pcpsha512unpack.c
new file mode 100644
index 0000000..dcacc70
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512unpack.c
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Unpack()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+/*F*
+// Name: ippsSHA512Unpack
+//
+// Purpose: Unpack buffer content into the initialized context.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pState == NULL
+// pBuffer== NULL
+// ippStsNoErr no errors
+//
+// Parameters:
+// pBuffer pointer to the input buffer
+// pState pointer hash state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Unpack,(const Ipp8u* pBuffer, IppsSHA512State* pState))
+{
+ /* test pointers */
+ IPP_BAD_PTR2_RET(pState, pBuffer);
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+
+ CopyBlock(pBuffer, pState, sizeof(IppsSHA512State));
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpsha512update.c b/ext/ipp/sources/ippcp/pcpsha512update.c
new file mode 100644
index 0000000..4a98e36
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsha512update.c
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SHA512 message digest
+//
+// Contents:
+// ippsSHA512Update()
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+#include "pcpsha512stuff.h"
+
+/*F*
+// Name: ippsSHA512Update
+//
+// Purpose: Updates intermadiate digest based on input stream.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pSrc == NULL
+// pState == NULL
+// ippStsContextMatchErr pState->idCtx != idCtxSHA512
+// ippStsLengthErr len <0
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the input stream
+// len input stream length
+// pState pointer to the SHA512 state
+//
+*F*/
+IPPFUN(IppStatus, ippsSHA512Update,(const Ipp8u* pSrc, int len, IppsSHA512State* pState))
+{
+ /* test state pointer and ID */
+ IPP_BAD_PTR1_RET(pState);
+ /* use aligned context */
+ pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) );
+ IPP_BADARG_RET(idCtxSHA512 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
+
+ /* test input length */
+ IPP_BADARG_RET((len<0), ippStsLengthErr);
+ /* test source pointer */
+ IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
+
+ /*
+ // handle non empty message
+ */
+ if(len) {
+ int procLen;
+
+ int idx = HAHS_BUFFIDX(pState);
+ Ipp8u* pBuffer = HASH_BUFF(pState);
+ Ipp64u lenLo = HASH_LENLO(pState) +len;
+ Ipp64u lenHi = HASH_LENHI(pState);
+ if(lenLo < HASH_LENLO(pState)) lenHi++;
+
+ /* if non empty internal buffer filling */
+ if(idx) {
+ /* copy from input stream to the internal buffer as match as possible */
+ procLen = IPP_MIN(len, (MBS_SHA512-idx));
+ CopyBlock(pSrc, pBuffer+idx, procLen);
+
+ /* update message pointer and length */
+ pSrc += procLen;
+ len -= procLen;
+ idx += procLen;
+
+ /* update digest if buffer full */
+ if(MBS_SHA512 == idx) {
+ UpdateSHA512(HASH_VALUE(pState), pBuffer, MBS_SHA512, sha512_cnt);
+ idx = 0;
+ }
+ }
+
+ /* main message part processing */
+ procLen = len & ~(MBS_SHA512-1);
+ if(procLen) {
+ UpdateSHA512(HASH_VALUE(pState), pSrc, procLen, sha512_cnt);
+ pSrc += procLen;
+ len -= procLen;
+ }
+
+ /* store rest of message into the internal buffer */
+ if(len) {
+ CopyBlock(pSrc, pBuffer, len);
+ idx += len;
+ }
+
+ /* update length of processed message */
+ HASH_LENLO(pState) = lenLo;
+ HASH_LENHI(pState) = lenHi;
+ HAHS_BUFFIDX(pState) = idx;
+ }
+
+ return ippStsNoErr;
+}
diff --git a/ext/ipp/sources/ippcp/pcpshsmgfca.c b/ext/ipp/sources/ippcp/pcpshsmgfca.c
new file mode 100644
index 0000000..64644ec
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpshsmgfca.c
@@ -0,0 +1,136 @@
+/*******************************************************************************
+* Copyright 2005-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// HASH based Mask Generation Functions
+//
+// Contents:
+// ippsMGF_SHA1()
+// ippsMGF_SHA224()
+// ippsMGF_SHA256()
+// ippsMGF_SHA384()
+// ippsMGF_SHA512()
+// ippsMGF_MD5()
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcptool.h"
+
+
+/*F*
+// Name: ippsMGF_SHA1
+// ippsMGF_SHA224
+// ippsMGF_SHA256
+// ippsMGF_SHA384
+// ippsMGF_SHA512
+// ippsMGF_MD5
+//
+// Purpose: Mask Generation Functions.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pMask == NULL
+// ippStsLengthErr seedLen <0
+// maskLen <0
+// ippStsNotSupportedModeErr if algID is not match to supported hash alg
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSeed pointer to the input stream
+// seedLen input stream length (bytes)
+// pMask pointer to the ouput mask
+// maskLen desired length of mask (bytes)
+// hashAlg identifier of the hash algorithm
+//
+*F*/
+IPPFUN(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg))
+{
+ /* get algorithm id */
+ hashAlg = cpValidHashAlg(hashAlg);
+ /* test hash alg */
+ IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
+
+ IPP_BAD_PTR1_RET(pMask);
+ IPP_BADARG_RET((seedLen<0)||(maskLen<0), ippStsLengthErr);
+
+ {
+ /* hash specific */
+ int hashSize = cpHashSize(hashAlg);
+
+ int i, outLen;
+
+ IppsHashState hashCtx;
+ ippsHashInit(&hashCtx, hashAlg);
+
+ if(!pSeed)
+ seedLen = 0;
+
+ for(i=0,outLen=0; outLen<maskLen; i++) {
+ Ipp8u cnt[4];
+ cnt[0] = (Ipp8u)((i>>24) & 0xFF);
+ cnt[1] = (Ipp8u)((i>>16) & 0xFF);
+ cnt[2] = (Ipp8u)((i>>8) & 0xFF);
+ cnt[3] = (Ipp8u)(i & 0xFF);
+
+ cpReInitHash(&hashCtx, hashAlg);
+ ippsHashUpdate(pSeed, seedLen, &hashCtx);
+ ippsHashUpdate(cnt, 4, &hashCtx);
+
+ if((outLen + hashSize) <= maskLen) {
+ ippsHashFinal(pMask+outLen, &hashCtx);
+ outLen += hashSize;
+ }
+ else {
+ Ipp8u md[MAX_HASH_SIZE];
+ ippsHashFinal(md, &hashCtx);
+ CopyBlock(md, pMask+outLen, maskLen-outLen);
+ outLen = maskLen;
+ }
+ }
+
+ return ippStsNoErr;
+ }
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpsm2pprecomca.c b/ext/ipp/sources/ippcp/pcpsm2pprecomca.c
index 7556d9e..4849514 100644
--- a/ext/ipp/sources/ippcp/src/pcpsm2pprecomca.c
+++ b/ext/ipp/sources/ippcp/pcpsm2pprecomca.c
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
//
diff --git a/ext/ipp/sources/ippcp/pcpsm3stuff.h b/ext/ipp/sources/ippcp/pcpsm3stuff.h
new file mode 100644
index 0000000..0fccd9c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsm3stuff.h
@@ -0,0 +1,119 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Digesting message according to SM3
+//
+// Contents:
+// SM3 methods and constants
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcphash.h"
+#include "pcphash_rmf.h"
+#include "pcptool.h"
+
+#if !defined _PCP_SM3_STUFF_H
+#define _PCP_SM3_STUFF_H
+
+/* SM3 constants */
+static const Ipp32u sm3_iv[] = {
+ 0x7380166F, 0x4914B2B9, 0x172442D7, 0xDA8A0600,
+ 0xA96F30BC, 0x163138AA, 0xE38DEE4D, 0xB0FB0E4E};
+
+static __ALIGN16 const Ipp32u sm3_cnt[] = {
+ 0x79CC4519,0xF3988A32,0xE7311465,0xCE6228CB,0x9CC45197,0x3988A32F,0x7311465E,0xE6228CBC,
+ 0xCC451979,0x988A32F3,0x311465E7,0x6228CBCE,0xC451979C,0x88A32F39,0x11465E73,0x228CBCE6,
+ 0x9D8A7A87,0x3B14F50F,0x7629EA1E,0xEC53D43C,0xD8A7A879,0xB14F50F3,0x629EA1E7,0xC53D43CE,
+ 0x8A7A879D,0x14F50F3B,0x29EA1E76,0x53D43CEC,0xA7A879D8,0x4F50F3B1,0x9EA1E762,0x3D43CEC5,
+ 0x7A879D8A,0xF50F3B14,0xEA1E7629,0xD43CEC53,0xA879D8A7,0x50F3B14F,0xA1E7629E,0x43CEC53D,
+ 0x879D8A7A,0x0F3B14F5,0x1E7629EA,0x3CEC53D4,0x79D8A7A8,0xF3B14F50,0xE7629EA1,0xCEC53D43,
+ 0x9D8A7A87,0x3B14F50F,0x7629EA1E,0xEC53D43C,0xD8A7A879,0xB14F50F3,0x629EA1E7,0xC53D43CE,
+ 0x8A7A879D,0x14F50F3B,0x29EA1E76,0x53D43CEC,0xA7A879D8,0x4F50F3B1,0x9EA1E762,0x3D43CEC5
+};
+
+static void sm3_hashInit(void* pHash)
+{
+ /* setup initial digest */
+ ((Ipp32u*)pHash)[0] = sm3_iv[0];
+ ((Ipp32u*)pHash)[1] = sm3_iv[1];
+ ((Ipp32u*)pHash)[2] = sm3_iv[2];
+ ((Ipp32u*)pHash)[3] = sm3_iv[3];
+ ((Ipp32u*)pHash)[4] = sm3_iv[4];
+ ((Ipp32u*)pHash)[5] = sm3_iv[5];
+ ((Ipp32u*)pHash)[6] = sm3_iv[6];
+ ((Ipp32u*)pHash)[7] = sm3_iv[7];
+}
+
+static void sm3_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
+{
+ UpdateSM3(pHash, pMsg, msgLen, sm3_cnt);
+}
+
+static void sm3_hashOctString(Ipp8u* pMD, void* pHashVal)
+{
+ /* convert hash into big endian */
+ ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
+ ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
+ ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
+ ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
+ ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
+ ((Ipp32u*)pMD)[5] = ENDIANNESS32(((Ipp32u*)pHashVal)[5]);
+ ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[6]);
+ ((Ipp32u*)pMD)[7] = ENDIANNESS32(((Ipp32u*)pHashVal)[7]);
+}
+
+static void sm3_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
+{
+ UNREFERENCED_PARAMETER(lenHi);
+ lenLo = ENDIANNESS64(lenLo<<3);
+ ((Ipp64u*)(pDst))[0] = lenLo;
+}
+
+#define cpFinalizeSM3 OWNAPI(cpFinalizeSM3)
+void cpFinalizeSM3(DigestSHA1 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen);
+
+#endif /* #if !defined _PCP_SM3_STUFF_H */
diff --git a/ext/ipp/sources/ippcp/pcpsms4.h b/ext/ipp/sources/ippcp/pcpsms4.h
new file mode 100644
index 0000000..f211ffb
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4.h
@@ -0,0 +1,201 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Internal Definitions and
+// Internal SMS4 Function Prototypes
+//
+//
+*/
+
+#if !defined(_PCP_SMS4_H)
+#define _PCP_SMS4_H
+
+#include "owncp.h"
+
+struct _cpSMS4 {
+ IppCtxId idCtx; /* SMS4 spec identifier */
+ Ipp32u enc_rkeys[32]; /* enc round keys */
+ Ipp32u dec_rkeys[32]; /* enc round keys */
+};
+
+/*
+// access macros
+*/
+#define SMS4_ID(ctx) ((ctx)->idCtx)
+#define SMS4_RK(ctx) ((ctx)->enc_rkeys)
+#define SMS4_ERK(ctx) ((ctx)->enc_rkeys)
+#define SMS4_DRK(ctx) ((ctx)->dec_rkeys)
+
+/* SMS4 data block size (bytes) */
+#define MBS_SMS4 (16)
+
+/* valid SMS4 context ID */
+#define VALID_SMS4_ID(ctx) (SMS4_ID((ctx))==idCtxSMS4)
+
+/* alignment of AES context */
+#define SMS4_ALIGNMENT (4)
+
+/* size of SMS4 context */
+__INLINE int cpSizeofCtx_SMS4(void)
+{
+ return sizeof(IppsSMS4Spec) +(SMS4_ALIGNMENT-1);
+}
+
+/* SMS4 constants */
+extern const __ALIGN64 Ipp8u SMS4_Sbox[16*16];
+extern const Ipp32u SMS4_FK[4];
+extern const Ipp32u SMS4_CK[32];
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+/* S-box substitution (endian dependent!) */
+
+#include "pcpbnuimpl.h"
+#define SELECTION_BITS ((sizeof(BNU_CHUNK_T)/sizeof(Ipp8u)) -1)
+
+#if defined(__INTEL_COMPILER)
+__INLINE Ipp8u getSboxValue(Ipp8u x)
+{
+ BNU_CHUNK_T selection = 0;
+ const BNU_CHUNK_T* SboxEntry = (BNU_CHUNK_T*)SMS4_Sbox;
+
+ BNU_CHUNK_T i_sel = x/sizeof(BNU_CHUNK_T); /* selection index */
+ BNU_CHUNK_T i;
+ for(i=0; i<sizeof(SMS4_Sbox)/sizeof(BNU_CHUNK_T); i++) {
+ BNU_CHUNK_T mask = (i==i_sel)? (BNU_CHUNK_T)(-1) : 0; /* ipp and IPP build specific avoid jump instruction here */
+ selection |= SboxEntry[i] & mask;
+ }
+ selection >>= (x & SELECTION_BITS)*8;
+ return (Ipp8u)(selection & 0xFF);
+}
+#else
+#include "pcpmask_ct.h"
+__INLINE Ipp8u getSboxValue(Ipp8u x)
+{
+ BNU_CHUNK_T selection = 0;
+ const BNU_CHUNK_T* SboxEntry = (BNU_CHUNK_T*)SMS4_Sbox;
+
+ Ipp32u _x = x/sizeof(BNU_CHUNK_T);
+ Ipp32u i;
+ for(i=0; i<sizeof(SMS4_Sbox)/sizeof(BNU_CHUNK_T); i++) {
+ BNS_CHUNK_T mask = cpIsEqu_ct(_x, i);
+ selection |= SboxEntry[i] & mask;
+ }
+ selection >>= (x & SELECTION_BITS)*8;
+ return (Ipp8u)(selection & 0xFF);
+}
+#endif
+
+__INLINE Ipp32u cpSboxT_SMS4(Ipp32u x)
+{
+ Ipp32u y = getSboxValue(x & 0xFF);
+ y |= getSboxValue((x>> 8) & 0xFF) <<8;
+ y |= getSboxValue((x>>16) & 0xFF) <<16;
+ y |= getSboxValue((x>>24) & 0xFF) <<24;
+ return y;
+}
+
+/* key expansion transformation:
+ - linear Lilear
+ - mixer Mix
+*/
+__INLINE Ipp32u cpExpKeyLinear_SMS4(Ipp32u x)
+{
+ return x^ROL32(x,13)^ROL32(x,23);
+}
+
+__INLINE Ipp32u cpExpKeyMix_SMS4(Ipp32u x)
+{
+ return cpExpKeyLinear_SMS4( cpSboxT_SMS4(x) );
+}
+
+/* cipher transformations:
+ - linear Lilear
+ - mixer Mix
+*/
+__INLINE Ipp32u cpCipherLinear_SMS4(Ipp32u x)
+{
+ return x^ROL32(x,2)^ROL32(x,10)^ROL32(x,18)^ROL32(x,24);
+}
+
+__INLINE Ipp32u cpCipherMix_SMS4(Ipp32u x)
+{
+ return cpCipherLinear_SMS4( cpSboxT_SMS4(x) );
+}
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#define cpSMS4_Cipher OWNAPI(cpSMS4_Cipher)
+void cpSMS4_Cipher(Ipp8u* otxt, const Ipp8u* itxt, const Ipp32u* pRoundKeys);
+
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+#define cpSMS4_SetRoundKeys_aesni OWNAPI(cpSMS4_SetRoundKeys_aesni)
+void cpSMS4_SetRoundKeys_aesni(Ipp32u* pRounKey, const Ipp8u* pSecretKey);
+
+#define cpSMS4_ECB_aesni_x1 OWNAPI(cpSMS4_ECB_aesni_x1)
+ void cpSMS4_ECB_aesni_x1(Ipp8u* pOut, const Ipp8u* pInp, const Ipp32u* pRKey);
+#define cpSMS4_ECB_aesni OWNAPI(cpSMS4_ECB_aesni)
+int cpSMS4_ECB_aesni(Ipp8u* pDst, const Ipp8u* pSrc, int nLen, const Ipp32u* pRKey);
+#define cpSMS4_CBC_dec_aesni OWNAPI(cpSMS4_CBC_dec_aesni)
+int cpSMS4_CBC_dec_aesni(Ipp8u* pDst, const Ipp8u* pSrc, int nLen, const Ipp32u* pRKey, Ipp8u* pIV);
+#define cpSMS4_CTR_aesni OWNAPI(cpSMS4_CTR_aesni)
+int cpSMS4_CTR_aesni(Ipp8u* pOut, const Ipp8u* pInp, int len, const Ipp32u* pRKey, const Ipp8u* pCtrMask, Ipp8u* pCtr);
+
+#if (_IPP>=_IPP_H9) || (_IPP32E>=_IPP32E_L9)
+#define cpSMS4_ECB_aesni_x12 OWNAPI(cpSMS4_ECB_aesni_x12)
+ int cpSMS4_ECB_aesni_x12(Ipp8u* pOut, const Ipp8u* pInp, int len, const Ipp32u* pRKey);
+#define cpSMS4_CBC_dec_aesni_x12 OWNAPI(cpSMS4_CBC_dec_aesni_x12)
+ int cpSMS4_CBC_dec_aesni_x12(Ipp8u* pOut, const Ipp8u* pInp, int len, const Ipp32u* pRKey, Ipp8u* pIV);
+#define cpSMS4_CTR_aesni_x4 OWNAPI(cpSMS4_CTR_aesni_x4)
+ int cpSMS4_CTR_aesni_x4(Ipp8u* pOut, const Ipp8u* pInp, int len, const Ipp32u* pRKey, const Ipp8u* pCtrMask, Ipp8u* pCtr);
+#endif
+
+#endif
+
+#define cpProcessSMS4_ctr OWNAPI(cpProcessSMS4_ctr)
+IppStatus cpProcessSMS4_ctr(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen, const IppsSMS4Spec* pCtx, Ipp8u* pCtrValue, int ctrNumBitSize);
+
+#define cpSMS4_SetRoundKeys OWNAPI(cpSMS4_SetRoundKeys)
+void cpSMS4_SetRoundKeys(Ipp32u* pRounKey, const Ipp8u* pKey);
+
+#endif /* _PCP_SMS4_H */
diff --git a/ext/ipp/sources/ippcp/pcpsms4_decrypt_cbc.h b/ext/ipp/sources/ippcp/pcpsms4_decrypt_cbc.h
new file mode 100644
index 0000000..d1cba3f
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4_decrypt_cbc.h
@@ -0,0 +1,121 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SMS4 encryption/decryption
+//
+// Contents:
+// cpDecryptSMS4_cbc()
+//
+*/
+
+#include "owncp.h"
+#include "pcpsms4.h"
+#include "pcptool.h"
+
+#if !defined _PCP_SMS4_DECRYPT_CBC_H
+#define _PCP_SMS4_DECRYPT_CBC_H
+
+/*F*
+// Name: ippsSMS4DecryptCBC
+//
+// Purpose: SMS4-CBC decryption.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx == NULL
+// pSrc == NULL
+// pDst == NULL
+// pIV == NULL
+// ippStsContextMatchErr !VALID_SMS4_ID()
+// ippStsLengthErr len <1
+// ippStsUnderRunErr 0!=(dataLen%MBS_SMS4)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// dataLen input/output buffer length (in bytes)
+// pCtx pointer to the SMS4 context
+// pIV pointer to the initialization vector
+//
+*F*/
+static void cpDecryptSMS4_cbc(const Ipp8u* pIV,
+ const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
+ const IppsSMS4Spec* pCtx)
+{
+ const Ipp32u* pRoundKeys = SMS4_DRK(pCtx);
+
+ /* copy IV */
+ Ipp32u iv[MBS_SMS4/sizeof(Ipp32u)];
+ CopyBlock16(pIV, iv);
+
+ /* do decryption */
+ #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+ if(IsFeatureEnabled(ippCPUID_AES)) {
+ int processedLen = cpSMS4_CBC_dec_aesni(pDst, pSrc, dataLen, pRoundKeys, (Ipp8u*)iv);
+ pSrc += processedLen;
+ pDst += processedLen;
+ dataLen -= processedLen;
+ }
+ #endif
+
+ for(; dataLen>0; dataLen-=MBS_SMS4, pSrc+=MBS_SMS4, pDst+=MBS_SMS4) {
+ Ipp32u tmp[MBS_SMS4/sizeof(ipp32u)];
+
+ cpSMS4_Cipher((Ipp8u*)tmp, (Ipp8u*)pSrc, pRoundKeys);
+
+ tmp[0] ^= iv[0];
+ tmp[1] ^= iv[1];
+ tmp[2] ^= iv[2];
+ tmp[3] ^= iv[3];
+
+ iv[0] = ((Ipp32u*)pSrc)[0];
+ iv[1] = ((Ipp32u*)pSrc)[1];
+ iv[2] = ((Ipp32u*)pSrc)[2];
+ iv[3] = ((Ipp32u*)pSrc)[3];
+
+ CopyBlock16(tmp, pDst);
+ }
+}
+
+#endif /* #if !defined _PCP_SMS4_DECRYPT_CBC_H */
diff --git a/ext/ipp/sources/ippcp/pcpsms4_encrypt_cbc.h b/ext/ipp/sources/ippcp/pcpsms4_encrypt_cbc.h
new file mode 100644
index 0000000..c61c048
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4_encrypt_cbc.h
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SMS4 encryption/decryption
+//
+// Contents:
+// cpEncryptSMS4_cbc()
+//
+*/
+
+#include "owncp.h"
+#include "pcpsms4.h"
+#include "pcptool.h"
+
+#if !defined _PCP_SMS4_ENCRYPT_CBC_H
+#define _PCP_SMS4_ENCRYPT_CBC_H
+
+/*F*
+// Name: ippsSMS4EncryptCBC
+//
+// Purpose: SMS4-CBC encryption.
+//
+// Returns: Reason:
+// ippStsNullPtrErr pCtx == NULL
+// pSrc == NULL
+// pDst == NULL
+// pIV == NULL
+// ippStsContextMatchErr !VALID_SMS_ID()
+// ippStsLengthErr len <1
+// ippStsUnderRunErr 0!=(dataLen%MBS_SMS4)
+// ippStsNoErr no errors
+//
+// Parameters:
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// dataLen input/output buffer length (in bytes)
+// pCtx pointer to the SMS4 context
+// pIV pointer to the initialization vector
+//
+*F*/
+static void cpEncryptSMS4_cbc(const Ipp8u* pIV,
+ const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
+ const IppsSMS4Spec* pCtx)
+{
+ const Ipp32u* pRoundKeys = SMS4_RK(pCtx);
+
+ /* read IV */
+ Ipp32u iv[MBS_SMS4/sizeof(Ipp32u)];
+ CopyBlock16(pIV, iv);
+
+ /* do encryption */
+ for(; dataLen>0; dataLen-=MBS_SMS4, pSrc+=MBS_SMS4, pDst+=MBS_SMS4) {
+ iv[0] ^= ((Ipp32u*)pSrc)[0];
+ iv[1] ^= ((Ipp32u*)pSrc)[1];
+ iv[2] ^= ((Ipp32u*)pSrc)[2];
+ iv[3] ^= ((Ipp32u*)pSrc)[3];
+
+ cpSMS4_Cipher(pDst, (Ipp8u*)iv, pRoundKeys);
+
+ iv[0] = ((Ipp32u*)pDst)[0];
+ iv[1] = ((Ipp32u*)pDst)[1];
+ iv[2] = ((Ipp32u*)pDst)[2];
+ iv[3] = ((Ipp32u*)pDst)[3];
+ }
+}
+
+#endif /* #if !defined _PCP_SMS4_ENCRYPT_CBC_H */
diff --git a/ext/ipp/sources/ippcp/pcpsms4_process_ofb8.h b/ext/ipp/sources/ippcp/pcpsms4_process_ofb8.h
new file mode 100644
index 0000000..53633ee
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4_process_ofb8.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright 2013-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SMS4 encryption/decryption
+//
+// Contents:
+// cpProcessSMS4_ofb8()
+//
+*/
+
+#include "owncp.h"
+#include "pcpsms4.h"
+#include "pcptool.h"
+
+#if !defined _PCP_SMS4_PROCESS_OFB8_H
+#define _PCP_SMS4_PROCESS_OFB8_H
+
+/*
+// SMS4-OFB ecnryption/decryption
+//
+// Parameters:
+// pSrc pointer to the source data buffer
+// pDst pointer to the target data buffer
+// dataLen input/output buffer length (in bytes)
+// ofbBlkSize ofb block size (in bytes)
+// pCtx pointer to the AES context
+// pIV pointer to the initialization vector
+*/
+static void cpProcessSMS4_ofb8(const Ipp8u *pSrc, Ipp8u *pDst, int dataLen, int ofbBlkSize,
+ const IppsSMS4Spec* pCtx,
+ Ipp8u* pIV)
+{
+ Ipp32u tmpInpOut[2*MBS_SMS4/sizeof(Ipp32u)];
+
+ CopyBlock16(pIV, tmpInpOut);
+
+ while(dataLen>=ofbBlkSize) {
+ /* block-by-block processing */
+ cpSMS4_Cipher((Ipp8u*)tmpInpOut+MBS_SMS4, (Ipp8u*)tmpInpOut, SMS4_RK(pCtx));
+
+ /* store output and shift inpBuffer for the next OFB operation */
+ if(ofbBlkSize==MBS_SMS4) {
+ ((Ipp32u*)pDst)[0] = tmpInpOut[0+MBS_SMS4/sizeof(Ipp32u)]^((Ipp32u*)pSrc)[0];
+ ((Ipp32u*)pDst)[1] = tmpInpOut[1+MBS_SMS4/sizeof(Ipp32u)]^((Ipp32u*)pSrc)[1];
+ ((Ipp32u*)pDst)[2] = tmpInpOut[2+MBS_SMS4/sizeof(Ipp32u)]^((Ipp32u*)pSrc)[2];
+ ((Ipp32u*)pDst)[3] = tmpInpOut[3+MBS_SMS4/sizeof(Ipp32u)]^((Ipp32u*)pSrc)[3];
+ tmpInpOut[0] = tmpInpOut[0+MBS_SMS4/sizeof(Ipp32u)];
+ tmpInpOut[1] = tmpInpOut[1+MBS_SMS4/sizeof(Ipp32u)];
+ tmpInpOut[2] = tmpInpOut[2+MBS_SMS4/sizeof(Ipp32u)];
+ tmpInpOut[3] = tmpInpOut[3+MBS_SMS4/sizeof(Ipp32u)];
+ }
+ else {
+ XorBlock(pSrc, tmpInpOut+MBS_SMS4/sizeof(Ipp32u), pDst, ofbBlkSize);
+ CopyBlock16((Ipp8u*)tmpInpOut+ofbBlkSize, tmpInpOut);
+ }
+
+ pSrc += ofbBlkSize;
+ pDst += ofbBlkSize;
+ dataLen -= ofbBlkSize;
+ }
+
+ /* update pIV */
+ CopyBlock16((Ipp8u*)tmpInpOut, pIV);
+}
+
+#endif /* #if !defined _PCP_SMS4_PROCESS_OFB8_H */
diff --git a/ext/ipp/sources/ippcp/pcpsms4authccm.h b/ext/ipp/sources/ippcp/pcpsms4authccm.h
new file mode 100644
index 0000000..d82b914
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4authccm.h
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* Copyright 2017-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// Message Authentication Algorithm
+// Internal Definitions and Internal Functions Prototypes
+//
+//
+*/
+
+#if !defined(_CP_SMS4_CCM_H)
+#define _CP_SMS4_CCM_H
+
+#include "pcpsms4.h"
+
+struct _cpSMS4_CCM {
+ IppCtxId idCtx; /* CCM ID */
+
+ Ipp64u msgLen; /* length of message to be processed */
+ Ipp64u lenProcessed; /* message length has been processed */
+ Ipp32u tagLen; /* length of authentication tag */
+ Ipp32u counterVal; /* currnt couter value */
+ Ipp8u ctr0[MBS_SMS4]; /* counter value */
+ Ipp8u s0[MBS_SMS4]; /* S0 = ENC(CTR0) content */
+ Ipp8u si[MBS_SMS4]; /* Si = ENC(CTRi) content */
+ Ipp8u blk[MBS_SMS4]; /* temporary data container */
+ Ipp8u mac[MBS_SMS4]; /* current MAC value */
+
+ Ipp8u cipher[sizeof(IppsSMS4Spec)+SMS4_ALIGNMENT-1];
+};
+
+/* alignment */
+#define SMS4CCM_ALIGNMENT ((int)(sizeof(void*)))
+
+/*
+// access macros
+*/
+#define SMS4CCM_ID(stt) ((stt)->idCtx)
+#define SMS4CCM_MSGLEN(stt) ((stt)->msgLen)
+#define SMS4CCM_LENPRO(stt) ((stt)->lenProcessed)
+#define SMS4CCM_TAGLEN(stt) ((stt)->tagLen)
+#define SMS4CCM_COUNTER(stt) ((stt)->counterVal)
+#define SMS4CCM_CTR0(stt) ((stt)->ctr0)
+#define SMS4CCM_S0(stt) ((stt)->s0)
+#define SMS4CCM_Si(stt) ((stt)->si)
+#define SMS4CCM_BLK(stt) ((stt)->blk)
+#define SMS4CCM_MAC(stt) ((stt)->mac)
+#define SMS4CCM_CIPHER(stt) (IppsSMS4Spec*)(&((stt)->cipher))
+#define SMS4CCM_CIPHER_ALIGNED(stt) (IppsSMS4Spec*)( IPP_ALIGNED_PTR( ((stt)->cipher), SMS4_ALIGNMENT ) )
+
+/* valid context ID */
+#define VALID_SMS4CCM_ID(ctx) (SMS4CCM_ID((ctx))==idCtxAESCCM)
+
+static int cpSizeofCtx_SMS4CCM(void)
+{
+ return sizeof(IppsSMS4_CCMState) + SMS4CCM_ALIGNMENT-1;
+}
+
+/* Counter block formatter */
+static
+Ipp8u* CounterEnc(Ipp32u* pBuffer, int fmt, Ipp64u counter)
+{
+ #if (IPP_ENDIAN == IPP_LITTLE_ENDIAN)
+ pBuffer[0] = ENDIANNESS(HIDWORD(counter));
+ pBuffer[1] = ENDIANNESS(LODWORD(counter));
+ #else
+ pBuffer[0] = HIDWORD(counter);
+ pBuffer[1] = LODWORD(counter);
+ #endif
+ return (Ipp8u*)pBuffer + 8 - fmt;
+}
+
+#endif /* _CP_SMS4_CCM_H*/
diff --git a/ext/ipp/sources/ippcp/pcpsms4ecby8cn.h b/ext/ipp/sources/ippcp/pcpsms4ecby8cn.h
new file mode 100644
index 0000000..e3c13ac
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpsms4ecby8cn.h
@@ -0,0 +1,141 @@
+/*******************************************************************************
+* Copyright 2014-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// SMS4 ECB encryption/decryption
+//
+// Contents:
+// Internal stuff
+//
+//
+*/
+
+#include "owndefs.h"
+#include "owncp.h"
+#include "pcpsms4.h"
+
+#if !defined _PCP_SMS4_ECB_H
+#define _PCP_SMS4_ECB_H
+
+#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
+
+static __ALIGN16 Ipp8u inpMaskLO[] = {0x65,0x41,0xfd,0xd9,0x0a,0x2e,0x92,0xb6,0x0f,0x2b,0x97,0xb3,0x60,0x44,0xf8,0xdc};
+static __ALIGN16 Ipp8u inpMaskHI[] = {0x00,0xc9,0x67,0xae,0x80,0x49,0xe7,0x2e,0x4a,0x83,0x2d,0xe4,0xca,0x03,0xad,0x64};
+static __ALIGN16 Ipp8u outMaskLO[] = {0xd3,0x59,0x38,0xb2,0xcc,0x46,0x27,0xad,0x36,0xbc,0xdd,0x57,0x29,0xa3,0xc2,0x48};
+static __ALIGN16 Ipp8u outMaskHI[] = {0x00,0x50,0x14,0x44,0x89,0xd9,0x9d,0xcd,0xde,0x8e,0xca,0x9a,0x57,0x07,0x43,0x13};
+
+static __ALIGN16 Ipp8u encKey[] = {0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63};
+static __ALIGN16 Ipp8u maskSrows[] = {0x00,0x0d,0x0a,0x07,0x04,0x01,0x0e,0x0b,0x08,0x05,0x02,0x0f,0x0c,0x09,0x06,0x03};
+
+static __ALIGN16 Ipp8u lowBits4[] = {0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f};
+
+static __ALIGN16 Ipp8u swapBytes[] = {3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12};
+
+#define M128(mem) (*((__m128i*)((Ipp8u*)(mem))))
+
+/*
+// stuff
+*/
+__INLINE __m128i affine(__m128i x, __m128i maskLO, __m128i maskHI)
+{
+ __m128i T1 = _mm_and_si128(_mm_srli_epi64(x, 4), M128(lowBits4));
+ __m128i T0 = _mm_and_si128(x, M128(lowBits4));
+ T0 = _mm_shuffle_epi8(maskLO, T0);
+ T1 = _mm_shuffle_epi8(maskHI, T1);
+ return _mm_xor_si128(T0, T1);
+}
+
+__INLINE __m128i Ltag(__m128i x)
+{
+ __m128i T = _mm_slli_epi32(x, 13);
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x,19));
+ T = _mm_xor_si128(T, _mm_slli_epi32 (x,23));
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x, 9));
+ return T;
+}
+
+/*
+// ECB encryption/decryption
+*/
+#define TRANSPOSE_INP(K0,K1,K2,K3, T) \
+ T = _mm_unpacklo_epi32(K0, K1); \
+ K1 = _mm_unpackhi_epi32(K0, K1); \
+ K0 = _mm_unpacklo_epi32(K2, K3); \
+ K3 = _mm_unpackhi_epi32(K2, K3); \
+ \
+ K2 = _mm_unpacklo_epi64(K1, K3); \
+ K3 = _mm_unpackhi_epi64(K1, K3); \
+ K1 = _mm_unpackhi_epi64(T, K0); \
+ K0 = _mm_unpacklo_epi64(T, K0)
+
+#define TRANSPOSE_OUT(K0,K1,K2,K3, T) \
+ T = _mm_unpacklo_epi32(K1, K0); \
+ K0 = _mm_unpackhi_epi32(K1, K0); \
+ K1 = _mm_unpacklo_epi32(K3, K2); \
+ K3 = _mm_unpackhi_epi32(K3, K2); \
+ \
+ K2 = _mm_unpackhi_epi64(K1, T); \
+ T = _mm_unpacklo_epi64(K1, T); \
+ K1 = _mm_unpacklo_epi64(K3, K0); \
+ K0 = _mm_unpackhi_epi64(K3, K0); \
+ K3 = T
+
+__INLINE __m128i L(__m128i x)
+{
+ __m128i T = _mm_slli_epi32(x, 2);
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x,30));
+
+ T = _mm_xor_si128(T, _mm_slli_epi32 (x,10));
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x,22));
+
+ T = _mm_xor_si128(T, _mm_slli_epi32 (x,18));
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x,14));
+
+ T = _mm_xor_si128(T, _mm_slli_epi32 (x,24));
+ T = _mm_xor_si128(T, _mm_srli_epi32 (x, 8));
+ return T;
+}
+
+#endif /* _IPP_P8, _IPP32E_Y8 */
+
+#endif /* #if !defined _PCP_SMS4_ECB_H */
diff --git a/ext/ipp/sources/ippcp/src/pcptool.h b/ext/ipp/sources/ippcp/pcptool.h
index 7fc819c..607f9f0 100644
--- a/ext/ipp/sources/ippcp/src/pcptool.h
+++ b/ext/ipp/sources/ippcp/pcptool.h
@@ -1,19 +1,43 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+/******* FILE MODIFIED FROM ORIGINAL 2019u1 RELEASE TO AVOID WARNINGS *********/
/*
//
// Purpose:
@@ -23,8 +47,10 @@
//
*/
-#if !defined(_PC_TOOL_H)
-#define _PC_TOOL_H
+#if !defined(_CP_TOOL_H)
+#define _CP_TOOL_H
+
+#include "pcpmask_ct.h"
#define _NEW_COPY16_
#define _NEW_XOR16_
@@ -189,12 +215,13 @@ __INLINE int EquBlock(const void* pSrc1, const void* pSrc2, int len)
/* addition functions for CTR mode of diffenent block ciphers */
+#if 0
__INLINE void StdIncrement(Ipp8u* pCounter, int blkSize, int numSize)
{
int maskPosition = (blkSize-numSize)/8;
Ipp8u mask = (Ipp8u)( 0xFF >> (blkSize-numSize)%8 );
- /* save crytical byte */
+ /* save critical byte */
Ipp8u save = (Ipp8u)( pCounter[maskPosition] & ~mask );
int len = BITS2WORD8_SIZE(blkSize);
@@ -209,6 +236,29 @@ __INLINE void StdIncrement(Ipp8u* pCounter, int blkSize, int numSize)
pCounter[maskPosition] &= mask;
pCounter[maskPosition] |= save;
}
+#endif
+
+/* const-exe-time version */
+__INLINE void StdIncrement(Ipp8u* pCounter, int blkBitSize, int numSize)
+{
+ int maskPosition = (blkBitSize -numSize)/8;
+ Ipp8u maskVal = (Ipp8u)( 0xFF >> (blkBitSize -numSize)%8 );
+
+ int i;
+ Ipp32u carry = 1;
+ for(i=BITS2WORD8_SIZE(blkBitSize)-1; i>=0; i--) {
+ int d = maskPosition - i;
+ Ipp8u mask = maskVal | (Ipp8u)cpIsMsb_ct(d);
+
+ Ipp32u x = pCounter[i] + carry;
+ Ipp8u y = pCounter[i];
+ pCounter[i] = (Ipp8u)((y & ~mask) | (x & mask));
+
+ maskVal &= cpIsMsb_ct(d);
+
+ carry = (x>>8) & 0x1;
+ }
+}
/* vb */
__INLINE void ompStdIncrement64( void* pInitCtrVal, void* pCurrCtrVal,
@@ -358,7 +408,7 @@ __INLINE void ompStdIncrement128( void* pInitCtrVal, void* pCurrCtrVal,
#endif
}
-
+#if 0
/* vb */
__INLINE void ompStdIncrement192( void* pInitCtrVal, void* pCurrCtrVal,
int ctrNumBitSize, int n )
@@ -482,8 +532,9 @@ __INLINE void ompStdIncrement192( void* pInitCtrVal, void* pCurrCtrVal,
}
#endif
}
+#endif
-
+#if 0
/* vb */
__INLINE void ompStdIncrement256( void* pInitCtrVal, void* pCurrCtrVal,
int ctrNumBitSize, int n )
@@ -653,5 +704,6 @@ __INLINE void ompStdIncrement256( void* pInitCtrVal, void* pCurrCtrVal,
}
#endif
}
+#endif
#endif /* _CP_TOOL_H */
diff --git a/ext/ipp/sources/ippcp/pcptrngenhwca.c b/ext/ipp/sources/ippcp/pcptrngenhwca.c
new file mode 100644
index 0000000..52fd8af
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcptrngenhwca.c
@@ -0,0 +1,226 @@
+/*******************************************************************************
+* Copyright 2015-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Purpose:
+// Cryptography Primitive.
+// TRNG Functions
+//
+// Contents:
+// ippsTRNGenHW()
+// ippsTRNGenHW_BN()
+//
+//
+*/
+
+#include "owndefs.h"
+
+#include "owncp.h"
+#include "pcpbn.h"
+#include "pcptool.h"
+
+#if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+static int cpSeed_hw_sample(BNU_CHUNK_T* pSample)
+{
+#define LOCAL_COUNTER (32) /* this constant has been tuned manually stated from 1024, looks that 16 is enouhg, but increased twice */
+ int n;
+ int success = 0;
+ for(n=0; n<LOCAL_COUNTER && !success; n++)
+ #if (_IPP_ARCH == _IPP_ARCH_IA32)
+ success = _rdseed32_step(pSample);
+ #elif (_IPP_ARCH == _IPP_ARCH_EM64T)
+ #pragma warning(push) // temporary, compiler bug workaround
+ #pragma warning(disable : 167)
+ success = _rdseed64_step(pSample);
+ #pragma warning(pop)
+ #else
+ #error Unknown CPU arch
+ #endif
+ return success;
+#undef LOCAL_COUNTER
+}
+
+#if (_IPP32E>=_IPP32E_E9)
+static int cpSeed_hw_sample32(Ipp32u* pSample)
+{
+#define LOCAL_COUNTER (32) /* this constant has been tuned manually stated from 1024, looks that 16 is enouhg, but increased twice */
+ int n;
+ int success = 0;
+ for(n=0; n<LOCAL_COUNTER && !success; n++)
+ success = _rdseed32_step(pSample);
+ return success;
+#undef LOCAL_COUNTER
+}
+#endif
+
+static int cpSeedHW_buffer(Ipp32u* pRand, int bufLen)
+{
+ int nSamples = bufLen/(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
+
+ int n;
+ /* collect nSamples randoms */
+ for(n=0; n<nSamples; n++, pRand+=(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
+ if( !cpSeed_hw_sample((BNU_CHUNK_T*)pRand))
+ return 0;
+ }
+
+ #if (_IPP32E>=_IPP32E_E9)
+ if( bufLen%(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)) ) {
+ if( !cpSeed_hw_sample32(pRand)) {
+ return 0;
+ }
+ }
+ #endif
+ return 1;
+}
+#endif
+
+/*F*
+// Name: ippsTRNGenRDSEED
+//
+// Purpose: Generates a true random bit sequence
+// based on Intel(R) instruction RDSEED of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pRand
+//
+// ippStsLengthErr 1 > nBits
+//
+// ippStsNotSupportedModeErr unsupported rdrand instruction
+//
+// ippStsErr random bit sequence can't be generated
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the buffer
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsTRNGenRDSEED,(Ipp32u* pRand, int nBits, void* pCtx))
+{
+ /* test PRNG buffer */
+ IPP_BAD_PTR1_RET(pRand);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+
+ UNREFERENCED_PARAMETER(pCtx);
+
+ #if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+ if( IsFeatureEnabled(ippCPUID_RDSEED) ) {
+ cpSize rndSize = BITS2WORD32_SIZE(nBits);
+ Ipp32u rndMask = MAKEMASK32(nBits);
+
+ if(cpSeedHW_buffer(pRand, rndSize)) {
+ pRand[rndSize-1] &= rndMask;
+ return ippStsNoErr;
+ }
+ else
+ return ippStsErr;
+ }
+ /* unsupported rdrand instruction */
+ else
+ #endif
+ IPP_ERROR_RET(ippStsNotSupportedModeErr);
+}
+
+
+/*F*
+// Name: ippsTRNGenRDSEED_BN
+//
+// Purpose: Generates a true random big number
+// based on Intel(R) instruction RDSEED of the specified nBits length.
+//
+// Returns: Reason:
+// ippStsNullPtrErr NULL == pRand
+//
+// ippStsLengthErr 1 > nBits
+// nBits > BN_ROOM(pRand)
+//
+// ippStsNotSupportedModeErr unsupported rdrand instruction
+//
+// ippStsErr random big number can't be generated
+//
+// ippStsNoErr no error
+//
+// Parameters:
+// pRand pointer to the big number
+// nBits number of bits be requested
+// pCtx pointer to the context
+*F*/
+IPPFUN(IppStatus, ippsTRNGenRDSEED_BN,(IppsBigNumState* pRand, int nBits, void* pCtx))
+{
+ /* test random BN */
+ IPP_BAD_PTR1_RET(pRand);
+ pRand = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRand, BN_ALIGNMENT) );
+ IPP_BADARG_RET(!BN_VALID_ID(pRand), ippStsContextMatchErr);
+
+ /* test sizes */
+ IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
+ IPP_BADARG_RET(nBits> BN_ROOM(pRand)*BNU_CHUNK_BITS, ippStsLengthErr);
+
+ UNREFERENCED_PARAMETER(pCtx);
+
+ #if ((_IPP>=_IPP_G9) || (_IPP32E>=_IPP32E_E9))
+ if( IsFeatureEnabled(ippCPUID_RDSEED) ) {
+ BNU_CHUNK_T* pRandBN = BN_NUMBER(pRand);
+ cpSize rndSize = BITS_BNU_CHUNK(nBits);
+ BNU_CHUNK_T rndMask = MASK_BNU_CHUNK(nBits);
+
+ if(cpSeedHW_buffer((Ipp32u*)pRandBN, rndSize*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
+ pRandBN[rndSize-1] &= rndMask;
+
+ FIX_BNU(pRandBN, rndSize);
+ BN_SIZE(pRand) = rndSize;
+ BN_SIGN(pRand) = ippBigNumPOS;
+
+ return ippStsNoErr;
+ }
+ else
+ return ippStsErr;
+ }
+
+ /* unsupported rdrand instruction */
+ else
+ #endif
+ IPP_ERROR_RET(ippStsNotSupportedModeErr);
+}
diff --git a/ext/ipp/sources/ippcp/src/pcpvariant.h b/ext/ipp/sources/ippcp/pcpvariant.h
index bbfd60f..270e9a3 100644
--- a/ext/ipp/sources/ippcp/src/pcpvariant.h
+++ b/ext/ipp/sources/ippcp/pcpvariant.h
@@ -1,18 +1,42 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
+/*******************************************************************************
+* Copyright 2005-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
/*
// Intel(R) Integrated Performance Primitives
@@ -89,7 +113,7 @@
#endif
/*
-// IPP supports several hash algorithms by default:
+// Intel(R) Integrated Performance Primitives (Intel(R) IPP) supports several hash algorithms by default:
// SHA-1
// SHA-256
// SHA-224 (or SHA256/224 by the FIPS180-4 classification)
@@ -98,7 +122,7 @@
// MD5
// SM3
//
-// By default all hash algorithms are included in IPP Crypto.
+// By default all hash algorithms are included in Intel(R) IPP Crypto.
//
// If one need excludes code of particular hash, just define
// suitable _DISABLE_ALG_XXX, where XXX name of the hash algorithm
@@ -159,7 +183,7 @@
#endif
/*
-// SHA1 plays especial role in IPP. Thus IPP random generator
+// SHA1 plays especial role in Intel(R) IPP. Thus Intel(R) IPP random generator
// and therefore prime number generator are based on SHA1.
// So, do no exclude SHA1 from the active list of hash algorithms
*/
@@ -170,7 +194,7 @@
/*
// Because of performane reason hash algorithms are implemented in form
// of unroller cycle and therefore these implementations are big enough.
-// IPP supports "compact" implementation of some basic hash algorithms:
+// Intel(R) IPP supports "compact" implementation of some basic hash algorithms:
// SHA-1
// SHA-256
// SHA-512
@@ -183,13 +207,13 @@
// _ALG_SM3_COMPACT_
//
// to select "compact" implementation of particular hash algorithm.
-// IPP does not define "compact" implementation by default.
+// Intel(R) IPP does not define "compact" implementation by default.
//
// Don't know what performance degradation leads "compact"
-// in comparison with default IPP implementation.
+// in comparison with default Intel(R) IPP implementation.
//
// Note: the definition like _ALG_XXX_COMPACT_ has effect
-// if and only if IPP instance is _PX or _MX
+// if and only if Intel(R) IPP instance is _PX or _MX
*/
//#define _ALG_SHA1_COMPACT_
//#define _ALG_SHA256_COMPACT_
@@ -207,7 +231,6 @@
// - do/don't use Karatsuba multiplication alg
*/
#define _USE_SQR_ /* use implementaton of sqr */
-#define xUSE_KARATSUBA_ /* not use Karatsuba method for multiplication */
#if !defined(_DISABLE_WINDOW_EXP_)
#define _USE_WINDOW_EXP_ /* use fixed window exponentiation */
#endif
@@ -215,17 +238,17 @@
/*
// RSA:
-// - do/don't use Ernie's style mitigation of CBA
-// - do/don't use Gres's style mitigation of CBA
-// - do/don't use Foldinf technique for RSA-1204 implementation
+// - do/don't use version 1 style mitigation of CBA
+// - do/don't use own style mitigation of CBA
+// - do/don't use Folding technique for RSA-1204 implementation
*/
-#define xUSE_ERNIE_CBA_MITIGATION_ /* not use (Ernie) mitigation of CBA */
-#define _USE_GRES_CBA_MITIGATION_ /* use (Gres) mitigation of CBA */
-#define xUSE_FOLD_MONT512_ /* use foding technique in RSA-1024 case */
+#define xUSE_VERSION1_CBA_MITIGATION_ /* not use (version 1) mitigation of CBA */
+#define _USE_IPP_OWN_CBA_MITIGATION_ /* use (own) mitigation of CBA */
+#define xUSE_FOLD_MONT512_ /* use folding technique in RSA-1024 case */
/*
-// IPP supports different implementation of NIST's (standard) EC over GF(0):
+// Intel(R) IPP supports different implementation of NIST's (standard) EC over GF(0):
// P-128 (IppECCPStd128r1, IppECCPStd128r2)
// P-192 (IppECCPStd192r1)
// P-224 (IppECCPStd224r1)
diff --git a/ext/ipp/sources/ippcp/pcpver.c b/ext/ipp/sources/ippcp/pcpver.c
new file mode 100644
index 0000000..dddb0f0
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpver.c
@@ -0,0 +1,118 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+*/
+
+#include "owndefs.h"
+#include "ippcpdefs.h"
+#include "owncp.h"
+#include "pcpver.h"
+#include "pcpname.h"
+
+#ifdef _IPP_OMP_STATIC
+#define LIB_THREADS " threaded"
+#else
+#define LIB_THREADS ""
+#endif
+
+#define GET_LIBRARY_NAME( cpu, is ) #cpu, IPP_LIB_SHORTNAME() " " is " (" #cpu LIB_THREADS ")"
+
+static const IppLibraryVersion ippcpLibVer = {
+ /* major, minor, update (ex-majorBuild) */
+ BASE_VERSION(),
+#if defined IPP_REVISION
+ IPP_REVISION,
+#else
+ -1,
+#endif /* IPP_REVISION */
+ /* targetCpu[4] */
+#if ( _IPP_ARCH == _IPP_ARCH_IA32 ) || ( _IPP_ARCH == _IPP_ARCH_LP32 )
+ #if ( _IPP == _IPP_M5 ) /* Intel(R) Quark(TM) processor - ia32 */
+ GET_LIBRARY_NAME( m5, "586" )
+ #elif ( _IPP == _IPP_H9 ) /* Intel(R) Advanced Vector Extensions 2 - ia32 */
+ GET_LIBRARY_NAME( h9, "AVX2" )
+ #elif ( _IPP == _IPP_G9 ) /* Intel(R) Advanced Vector Extensions - ia32 */
+ GET_LIBRARY_NAME( g9, "AVX" )
+ #elif ( _IPP == _IPP_P8 ) /* Intel(R) Streaming SIMD Extensions 4.2 - ia32 */
+ GET_LIBRARY_NAME( p8, "SSE4.2" )
+ #elif ( _IPP == _IPP_S8 ) /* Supplemental Streaming SIMD Extensions 3 + Intel(R) instruction MOVBE - ia32 */
+ GET_LIBRARY_NAME( s8, "Atom" )
+ #elif ( _IPP == _IPP_V8 ) /* Supplemental Streaming SIMD Extensions 3 - ia32 */
+ GET_LIBRARY_NAME( v8, "SSSE3" )
+ #elif ( _IPP == _IPP_W7 ) /* Intel(R) Streaming SIMD Extensions 2 - ia32 */
+ GET_LIBRARY_NAME( w7, "SSE2" )
+ #else
+ GET_LIBRARY_NAME( px, "PX" )
+ #endif
+
+#elif ( _IPP_ARCH == _IPP_ARCH_EM64T ) || ( _IPP_ARCH == _IPP_ARCH_LP64 )
+ #if ( _IPP32E == _IPP32E_K0 ) /* Intel(R) Advanced Vector Extensions 512 (formerly Skylake) - intel64 */
+ GET_LIBRARY_NAME( k0, "AVX-512F/CD/BW/DQ/VL" )
+ #elif ( _IPP32E == _IPP32E_N0 ) /* Intel(R) Advanced Vector Extensions 512 (formerly codenamed Knights Landing) - intel64 */
+ GET_LIBRARY_NAME( n0, "AVX-512F/CD/ER/PF" )
+ #elif ( _IPP32E == _IPP32E_E9 ) /* Intel(R) Advanced Vector Extensions - intel64 */
+ GET_LIBRARY_NAME( e9, "AVX" )
+ #elif ( _IPP32E == _IPP32E_L9 ) /* Intel(R) Advanced Vector Extensions 2 - intel64 */
+ GET_LIBRARY_NAME( l9, "AVX2" )
+ #elif ( _IPP32E == _IPP32E_Y8 ) /* Intel(R) Streaming SIMD Extensions 4.2 - intel64 */
+ GET_LIBRARY_NAME( y8, "SSE4.2" )
+ #elif ( _IPP32E == _IPP32E_N8 ) /* Supplemental Streaming SIMD Extensions 3 + Intel(R) instruction MOVBE - intel64 */
+ GET_LIBRARY_NAME( n8, "Atom" )
+ #elif ( _IPP32E == _IPP32E_U8 ) /* Supplemental Streaming SIMD Extensions 3 - intel64 */
+ GET_LIBRARY_NAME( u8, "SSSE3" )
+ #elif ( _IPP32E == _IPP32E_M7 ) /* Intel(R) Streaming SIMD Extensions 3 - intel64 */
+ GET_LIBRARY_NAME( m7, "SSE3" )
+ #else
+ GET_LIBRARY_NAME( mx, "PX" )
+ #endif
+#endif
+ ,STR_VERSION() /* release Version */
+ ,__DATE__ //BuildDate
+};
+
+IPPFUN( const IppLibraryVersion*, ippcpGetLibVersion, ( void )){
+ return &ippcpLibVer;
+};
+
+/*////////////////////////// End of file "pcpver.c" ////////////////////////// */
diff --git a/ext/ipp/sources/ippcp/pcpver.h b/ext/ipp/sources/ippcp/pcpver.h
new file mode 100644
index 0000000..160b50c
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpver.h
@@ -0,0 +1,54 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+// Intel(R) Integrated Performance Primitives
+// Cryptographic Primitives (ippcp)
+//
+// Purpose: Describes the version of ippCP
+//
+*/
+
+
+#include "ippver.h"
+#define BUILD() 1043
+#define VERSION() BASE_VERSION(),BUILD()
+
+/* ////////////////////////// End of file "pcpver.h" ///////////////////////// */
diff --git a/ext/ipp/sources/ippcp/pcpver.rc b/ext/ipp/sources/ippcp/pcpver.rc
new file mode 100644
index 0000000..711b770
--- /dev/null
+++ b/ext/ipp/sources/ippcp/pcpver.rc
@@ -0,0 +1,53 @@
+/*******************************************************************************
+* Copyright 2002-2018 Intel Corporation
+* All Rights Reserved.
+*
+* If this software was obtained under the Intel Simplified Software License,
+* the following terms apply:
+*
+* The source code, information and material ("Material") contained herein is
+* owned by Intel Corporation or its suppliers or licensors, and title to such
+* Material remains with Intel Corporation or its suppliers or licensors. The
+* Material contains proprietary information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright laws and treaty
+* provisions. No part of the Material may be used, copied, reproduced,
+* modified, published, uploaded, posted, transmitted, distributed or disclosed
+* in any way without Intel's prior express written permission. No license under
+* any patent, copyright or other intellectual property rights in the Material
+* is granted to or conferred upon you, either expressly, by implication,
+* inducement, estoppel or otherwise. Any license under such intellectual
+* property rights must be express and approved by Intel in writing.
+*
+* Unless otherwise agreed by Intel in writing, you may not remove or alter this
+* notice or any other notice embedded in Materials by Intel or Intel's
+* suppliers or licensors in any way.
+*
+*
+* If this software was obtained under the Apache License, Version 2.0 (the
+* "License"), the following terms apply:
+*
+* You may not use this file except in compliance with the License. You may
+* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+*
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/*
+//
+// Created: Tue Feb 5 17:02:02 2002
+//
+*/
+
+
+#include "pcpver.h"
+#include "pcpname.h"
+#include "ippres.gen"
+
+/* ////////////////////////////// End of file /////////////////////////////// */
+
diff --git a/ext/ipp/sources/ippcp/src/gsmodstuff.c b/ext/ipp/sources/ippcp/src/gsmodstuff.c
deleted file mode 100644
index ff8e00e..0000000
--- a/ext/ipp/sources/ippcp/src/gsmodstuff.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpbnumisc.h"
-#include "pcpbnuarith.h"
-#include "gsmodstuff.h"
-#include "pcptool.h"
-
-/* convert bitsize nbits into the number of BNU_CHUNK_T */
-#define BITS_BNU_IPP32U(nbits) (((nbits)+31)/32)
-
-/*
-// size of ModEngine context (Montgomery)
-*/
-IppStatus gsModEngineGetSize(int modulusBitSize, int numpe, int* pSize)
-{
- int modLen = BITS_BNU_CHUNK(modulusBitSize);
- int pelmLen = BITS_BNU_CHUNK(modulusBitSize);
-
- IPP_BADARG_RET(modulusBitSize<1, ippStsLengthErr);
- IPP_BADARG_RET(numpe<MOD_ENGINE_MIN_POOL_SIZE, ippStsLengthErr);
-
- /* allocates mimimal necessary to Montgomery based methods */
- *pSize = sizeof(gsModEngine)
- + modLen*sizeof(BNU_CHUNK_T) /* modulus */
- + modLen*sizeof(BNU_CHUNK_T) /* mont_R */
- + modLen*sizeof(BNU_CHUNK_T) /* mont_R^2 */
- + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* buffers */
-
- return ippStsNoErr;
-}
-
-/*
-// montfomery factor k0 = -((modulus^-1 mod B) %B)
-*/
-BNU_CHUNK_T gsMontFactor(BNU_CHUNK_T m0)
-{
- BNU_CHUNK_T y = 1;
- BNU_CHUNK_T x = 2;
- BNU_CHUNK_T mask = 2*x-1;
-
- int i;
- for(i=2; i<=BNU_CHUNK_BITS; i++, x<<=1) {
- BNU_CHUNK_T rH, rL;
- MUL_AB(rH, rL, m0, y);
- if( x < (rL & mask) ) /* x < ((m0*y) mod (2*x)) */
- y+=x;
- mask += mask + 1;
- }
- return 0-y;
-}
-
-/*
-// initialization of the ModEngine context (Montgomery)
-*/
-IppStatus gsModEngineInit(gsModEngine* pME, const Ipp32u* pModulus, int modulusBitSize, int numpe, const gsModMethod* method)
-{
- IPP_BADARG_RET(modulusBitSize<1, ippStsLengthErr);
- IPP_BADARG_RET((pModulus) && (pModulus[0] & 1) == 0, ippStsBadModulusErr);
- IPP_BADARG_RET(numpe<MOD_ENGINE_MIN_POOL_SIZE, ippStsLengthErr);
-
- {
- int pelmLen = BITS_BNU_CHUNK(modulusBitSize);
- int modLen = BITS_BNU_CHUNK(modulusBitSize);
- int modLen32 = BITS_BNU_IPP32U(modulusBitSize);
- Ipp8u* ptr = (Ipp8u*)pME;
-
- /* clear whole context */
- PaddBlock(0, pME, sizeof(gsModEngine));
-
- MOD_PARENT(pME) = NULL;
- MOD_EXTDEG(pME) = 1;
- MOD_BITSIZE(pME) = modulusBitSize;
- MOD_LEN(pME) = modLen;
- MOD_PELEN(pME) = pelmLen;
- MOD_METHOD(pME) = method;
- MOD_MODULUS(pME) = (BNU_CHUNK_T*)(ptr += sizeof(gsModEngine));
- MOD_MNT_R(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
- MOD_MNT_R2(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
- MOD_POOL_BUF(pME) = (BNU_CHUNK_T*)(ptr += modLen*sizeof(BNU_CHUNK_T));
- MOD_MAXPOOL(pME) = numpe;
- MOD_USEDPOOL(pME) = 0;
-
- if (pModulus) {
- /* store modulus */
- ZEXPAND_COPY_BNU((Ipp32u*)MOD_MODULUS(pME), modLen * (cpSize)(sizeof(BNU_CHUNK_T) / sizeof(Ipp32u)), pModulus, modLen32);
-
- /* montgomery factor */
- MOD_MNT_FACTOR(pME) = gsMontFactor(MOD_MODULUS(pME)[0]);
-
- /* montgomery identity (R) */
- ZEXPAND_BNU(MOD_MNT_R(pME), 0, modLen);
- MOD_MNT_R(pME)[modLen] = 1;
- cpMod_BNU(MOD_MNT_R(pME), modLen+1, MOD_MODULUS(pME), modLen);
-
- /* montgomery domain converter (RR) */
- ZEXPAND_BNU(MOD_MNT_R2(pME), 0, modLen);
- COPY_BNU(MOD_MNT_R2(pME)+modLen, MOD_MNT_R(pME), modLen);
- cpMod_BNU(MOD_MNT_R2(pME), 2*modLen, MOD_MODULUS(pME), modLen);
- }
- }
-
- return ippStsNoErr;
-}
-
-/*
-// pool management methods
-*/
-
-
-BNU_CHUNK_T* gsModGetPool(gsModEngine* pME)
-{
- BNU_CHUNK_T*
- pPool = (pME->poolLenUsed >= pME->poolLen)? NULL : MOD_BUFFER(pME, pME->poolLenUsed);
- return pPool;
-}
-
-/*
-// Pack/Unpack methods
-*/
-
-void gsPackModEngineCtx(const gsModEngine* pCtx, Ipp8u* pBuffer)
-{
- gsModEngine* pAlignedBuffer = (gsModEngine*)pBuffer;
-
- /* max modulus length */
- int modSize = MOD_LEN(pCtx);
- /* size of context (bytes) without cube and pool buffers */
- int ctxSize = sizeof(gsModEngine)
- +sizeof(BNU_CHUNK_T)*(modSize*3);
-
- CopyBlock(pCtx, pAlignedBuffer, ctxSize);
- MOD_MODULUS(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MODULUS(pCtx))-IPP_UINT_PTR(pCtx));
- MOD_MNT_R(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MNT_R(pCtx))-IPP_UINT_PTR(pCtx));
- MOD_MNT_R2(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MOD_MNT_R2(pCtx))-IPP_UINT_PTR(pCtx));
-}
-
-void gsUnpackModEngineCtx(const Ipp8u* pBuffer, gsModEngine* pCtx)
-{
- gsModEngine* pAlignedBuffer = (gsModEngine*)pBuffer;
-
- /* max modulus length */
- int modSize = MOD_LEN(pAlignedBuffer);
- /* size of context (bytes) without cube and pool buffers */
- int ctxSize = sizeof(gsModEngine)
- +sizeof(BNU_CHUNK_T)*(modSize*3);
-
- CopyBlock(pAlignedBuffer, pCtx, ctxSize);
- MOD_MODULUS(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MODULUS(pAlignedBuffer)));
- MOD_MNT_R(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MNT_R(pAlignedBuffer)));
- MOD_MNT_R2(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MOD_MNT_R2(pAlignedBuffer)));
- MOD_POOL_BUF(pCtx) = MOD_MNT_R2(pCtx) + modSize;
-}
diff --git a/ext/ipp/sources/ippcp/src/gsscramble.c b/ext/ipp/sources/ippcp/src/gsscramble.c
deleted file mode 100644
index 4313e48..0000000
--- a/ext/ipp/sources/ippcp/src/gsscramble.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*############################################################################
- # Copyright 2013-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Fixed window exponentiation scramble/unscramble
-//
-// Contents:
-// gsScramblePut()
-// gsScrambleGet()
-// gsScrambleGet_sscm()
-//
-*/
-#include "owncp.h"
-#include "gsscramble.h"
-
-int gsGetScrambleBufferSize(int modulusLen, int w)
-{
- /* size of resource to store 2^w values of modulusLen*sizeof(BNU_CHUNK_T) each */
- int size = (1<<w) * modulusLen * sizeof(BNU_CHUNK_T);
- /* padd it up to CACHE_LINE_SIZE */
- size += (CACHE_LINE_SIZE - (size % CACHE_LINE_SIZE)) %CACHE_LINE_SIZE;
- ///* add CACHE_LINE_SIZE for alignment purpose*/
- //size += CACHE_LINE_SIZE;
- return size/sizeof(BNU_CHUNK_T);
-}
-
-void gsScramblePut(BNU_CHUNK_T* tbl, int idx, const BNU_CHUNK_T* val, int vLen, int w)
-{
- int width = 1 << w;
- int i, j;
- for(i=0, j=idx; i<vLen; i++, j+= width) {
- tbl[j] = val[i];
- }
-}
-
-void gsScrambleGet(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w)
-{
- int width = 1 << w;
- int i, j;
- for(i=0, j=idx; i<vLen; i++, j+= width) {
- val[i] = tbl[j];
- }
-}
-
-void gsScrambleGet_sscm(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w)
-{
- BNU_CHUNK_T mask[1<<MAX_W];
-
- int width = 1 << w;
-
- int n, i;
- switch (w) {
- case 6:
- for(n=0; n<(1<<6); n++)
- mask[n] = (BNU_CHUNK_T)0 - (ct_eq_int(n,idx)&1);
- break;
- case 5:
- for(n=0; n<(1<<5); n++)
- mask[n] = (BNU_CHUNK_T)0 - (ct_eq_int(n,idx)&1);
- break;
- case 4:
- for(n=0; n<(1<<4); n++)
- mask[n] = (BNU_CHUNK_T)0 - (ct_eq_int(n,idx)&1);
- break;
- case 3:
- for(n=0; n<(1<<3); n++)
- mask[n] = (BNU_CHUNK_T)0 - (ct_eq_int(n,idx)&1);
- break;
- case 2:
- for(n=0; n<(1<<2); n++)
- mask[n] = (BNU_CHUNK_T)0 - (ct_eq_int(n,idx)&1);
- break;
- default:
- mask[0] = (BNU_CHUNK_T)0 - (ct_eq_int(0,idx)&1);
- mask[1] = (BNU_CHUNK_T)0 - (ct_eq_int(1,idx)&1);
- break;
- }
-
- for(i=0; i<vLen; i++, tbl += width) {
- BNU_CHUNK_T acc = 0;
-
- switch (w) {
- case 6:
- for(n=0; n<(1<<6); n++)
- acc |= tbl[n] & mask[n];
- break;
- case 5:
- for(n=0; n<(1<<5); n++)
- acc |= tbl[n] & mask[n];
- break;
- case 4:
- for(n=0; n<(1<<4); n++)
- acc |= tbl[n] & mask[n];
- break;
- case 3:
- for(n=0; n<(1<<3); n++)
- acc |= tbl[n] & mask[n];
- break;
- case 2:
- for(n=0; n<(1<<2); n++)
- acc |= tbl[n] & mask[n];
- break;
- default:
- acc |= tbl[0] & mask[0];
- acc |= tbl[1] & mask[1];
- break;
- }
-
- val[i] = acc;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/gsscramble.h b/ext/ipp/sources/ippcp/src/gsscramble.h
deleted file mode 100644
index a60be4e..0000000
--- a/ext/ipp/sources/ippcp/src/gsscramble.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*############################################################################
- # Copyright 2013-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Fixed window exponentiation scramble/unscramble
-//
-// Contents:
-// gsGetScrambleBufferSize()
-// gsScramblePut()
-// gsScrambleGet()
-// gsScrambleGet_sscm()
-//
-//
-*/
-
-#if !defined(_GS_SCRAMBLE_H)
-#define _GS_SCRAMBLE_H
-
-#include "pcpbnuimpl.h"
-
-#define MAX_W (6)
-
-__INLINE unsigned int ct_msb(unsigned int a)
-{
- return 0 - (a >> (sizeof(a) * 8 - 1));
-}
-
-__INLINE unsigned int ct_is_zero(unsigned int a)
-{
- return ct_msb(~a & (a - 1));
-}
-
-__INLINE unsigned int ct_eq(unsigned int a, unsigned int b)
-{
- return ct_is_zero(a ^ b);
-}
-
-__INLINE unsigned int ct_eq_int(int a, int b)
-{
- return ct_eq((unsigned)(a), (unsigned)(b));
-}
-
-#define gsGetScrambleBufferSize OWNAPI(gsGetScrambleBufferSize)
-int gsGetScrambleBufferSize(int modulusLen, int w);
-
-#define gsScramblePut OWNAPI(gsScramblePut)
-void gsScramblePut(BNU_CHUNK_T* tbl, int idx, const BNU_CHUNK_T* val, int vLen, int w);
-
-#define gsScrambleGet OWNAPI(gsScrambleGet)
-void gsScrambleGet(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w);
-
-#define gsScrambleGet_sscm OWNAPI(gsScrambleGet_sscm)
-void gsScrambleGet_sscm(BNU_CHUNK_T* val, int vLen, const BNU_CHUNK_T* tbl, int idx, int w);
-
-#endif /* _GS_SCRAMBLE_H */
diff --git a/ext/ipp/sources/ippcp/src/owncp.h b/ext/ipp/sources/ippcp/src/owncp.h
deleted file mode 100644
index 30f2c03..0000000
--- a/ext/ipp/sources/ippcp/src/owncp.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*############################################################################
- # Copyright 2002-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives (ippcp)
-*/
-
-#ifndef __OWNCP_H__
-#define __OWNCP_H__
-
-#ifndef __OWNDEFS_H__
- #include "owndefs.h"
-#endif
-
-#ifndef IPPCP_H__
- #include "ippcp.h"
-#endif
-
-/*
-// modes of the CPU feature
-*/
-#define _FEATURE_OFF_ (0) /* feature is OFF a priori */
-#define _FEATURE_ON_ (1) /* feature is ON a priori */
-#define _FEATURE_TICKTOCK_ (2) /* dectect is feature OFF/ON */
-
-//#define _ABL_
-#if defined(_ABL_)
-#include "pcpvariant_abl.h"
-#endif
-
-//#define _XMM7560_
-#if defined(_XMM7560_)
-# include "pcpvariant_xmm7560.h"
-//# pragma message ("standard configuration (pcpvariant.h) will be changed")
-#endif
-
-//#define _TXT_ACM_
-#if defined(_TXT_ACM_)
-# include "pcpvariant_txt_acm.h"
-#endif
-
-#include "pcpvariant.h"
-
-#pragma warning( disable : 4996 4324 4206)
-
-/* ippCP length */
-typedef int cpSize;
-
-/*
-// Common ippCP Macros
-*/
-
-/* size of cache line (bytes) */
-#if (_IPP==_IPP_M5)
-#define CACHE_LINE_SIZE (16)
-#define LOG_CACHE_LINE_SIZE (4)
-#else
-#define CACHE_LINE_SIZE (64)
-#define LOG_CACHE_LINE_SIZE (6)
-#endif
-
-/* swap data & pointers */
-#define SWAP_PTR(ATYPE, pX,pY) { ATYPE* aPtr=(pX); (pX)=(pY); (pY)=aPtr; }
-#define SWAP(x,y) {(x)^=(y); (y)^=(x); (x)^=(y);}
-
-/* alignment value */
-#define ALIGN_VAL ((int)sizeof(void*))
-
-/* bitsize */
-#define BYTESIZE (8)
-#define BITSIZE(x) ((int)(sizeof(x)*BYTESIZE))
-
-/* bit length -> byte/word length conversion */
-#define BITS2WORD8_SIZE(x) (((x)+ 7)>>3)
-#define BITS2WORD16_SIZE(x) (((x)+15)>>4)
-#define BITS2WORD32_SIZE(x) (((x)+31)>>5)
-#define BITS2WORD64_SIZE(x) (((x)+63)>>6)
-
-/* WORD and DWORD manipulators */
-#define LODWORD(x) ((Ipp32u)(x))
-#define HIDWORD(x) ((Ipp32u)(((Ipp64u)(x) >>32) & 0xFFFFFFFF))
-
-#define MAKEHWORD(bLo,bHi) ((Ipp16u)(((Ipp8u)(bLo)) | ((Ipp16u)((Ipp8u)(bHi))) << 8))
-#define MAKEWORD(hLo,hHi) ((Ipp32u)(((Ipp16u)(hLo)) | ((Ipp32u)((Ipp16u)(hHi))) << 16))
-#define MAKEDWORD(wLo,wHi) ((Ipp64u)(((Ipp32u)(wLo)) | ((Ipp64u)((Ipp32u)(wHi))) << 32))
-
-/* extract byte */
-#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n))))
-
-/* hexString <-> Ipp32u conversion */
-#define HSTRING_TO_U32(ptrByte) \
- (((ptrByte)[0]) <<24) \
- +(((ptrByte)[1]) <<16) \
- +(((ptrByte)[2]) <<8) \
- +((ptrByte)[3])
-#define U32_TO_HSTRING(ptrByte, x) \
- (ptrByte)[0] = (Ipp8u)((x)>>24); \
- (ptrByte)[1] = (Ipp8u)((x)>>16); \
- (ptrByte)[2] = (Ipp8u)((x)>>8); \
- (ptrByte)[3] = (Ipp8u)(x)
-
-/* 32- and 64-bit masks for MSB of nbits-sequence */
-#define MAKEMASK32(nbits) (0xFFFFFFFF >>((32 - ((nbits)&0x1F)) &0x1F))
-#define MAKEMASK64(nbits) (0xFFFFFFFFFFFFFFFF >>((64 - ((nbits)&0x3F)) &0x3F))
-
-/* Logical Shifts (right and left) of WORD */
-#define LSR32(x,nBits) ((x)>>(nBits))
-#define LSL32(x,nBits) ((x)<<(nBits))
-
-/* Rorate (right and left) of WORD */
-#if defined(_MSC_VER) && !defined( __ICL )
-# include <stdlib.h>
-# define ROR32(x, nBits) _lrotr((x),(nBits))
-# define ROL32(x, nBits) _lrotl((x),(nBits))
-#else
-# define ROR32(x, nBits) (LSR32((x),(nBits)) | LSL32((x),32-(nBits)))
-# define ROL32(x, nBits) ROR32((x),(32-(nBits)))
-#endif
-
-/* Logical Shifts (right and left) of DWORD */
-#define LSR64(x,nBits) ((x)>>(nBits))
-#define LSL64(x,nBits) ((x)<<(nBits))
-
-/* Rorate (right and left) of DWORD */
-#define ROR64(x, nBits) (LSR64((x),(nBits)) | LSL64((x),64-(nBits)))
-#define ROL64(x, nBits) ROR64((x),(64-(nBits)))
-
-/* change endian */
-#if defined(_MSC_VER)
-# define ENDIANNESS(x) _byteswap_ulong((x))
-# define ENDIANNESS32(x) ENDIANNESS((x))
-# define ENDIANNESS64(x) _byteswap_uint64((x))
-#elif defined(__ICL)
-# define ENDIANNESS(x) _bswap((x))
-# define ENDIANNESS32(x) ENDIANNESS((x))
-# define ENDIANNESS64(x) _bswap64((x))
-#else
-# define ENDIANNESS(x) ((ROR32((x), 24) & 0x00ff00ff) | (ROR32((x), 8) & 0xff00ff00))
-# define ENDIANNESS32(x) ENDIANNESS((x))
-# define ENDIANNESS64(x) MAKEDWORD(ENDIANNESS(HIDWORD((x))), ENDIANNESS(LODWORD((x))))
-#endif
-
-#define IPP_MAKE_MULTIPLE_OF_8(x) ((x) = ((x)+7)&(~7))
-#define IPP_MAKE_MULTIPLE_OF_16(x) ((x) = ((x)+15)&(~15))
-
-/* define 64-bit constant */
-#if !defined(__GNUC__)
- #define CONST_64(x) (x) /*(x##i64)*/
-#else
- #define CONST_64(x) (x##LL)
-#endif
-
-/* define 64-bit constant or pair of 32-bit dependding on architecture */
-#if ((_IPP_ARCH == _IPP_ARCH_EM64T) || (_IPP_ARCH == _IPP_ARCH_LP64) || (_IPP_ARCH == _IPP_ARCH_LRB) || (_IPP_ARCH == _IPP_ARCH_LRB2))
-#define LL(lo,hi) ((Ipp64u)(((Ipp32u)(lo)) | ((Ipp64u)((Ipp32u)(hi))) << 32))
-#define L_(lo) ((Ipp64u)(lo))
-#else
-#define LL(lo,hi) (lo),(hi)
-#define L_(lo) (lo)
-#endif
-
-
-/* crypto NI */
-#define AES_NI_ENABLED (ippCPUID_AES)
-#define CLMUL_NI_ENABLED (ippCPUID_CLMUL)
-#define AES_CLMUL_NI_ENABLED (ippCPUID_AES|ippCPUID_CLMUL)
-#define ADCOX_ENABLED (ippCPUID_ADCOX)
-#define SHA_NI_ENABLED (ippCPUID_SHA)
-#define RDRAND_NI_ENABLED (ippCPUID_RDRAND)
-#define RDSEED_NI_ENABLED (ippCPUID_RDSEED)
-
-int cpGetFeature( Ipp64u Feature );
-/* test CPU crypto features */
-__INLINE Ipp32u IsFeatureEnabled(Ipp64u niMmask)
-{
- return cpGetFeature(niMmask);
-}
-
-#define IPPCP_GET_NUM_THREADS() ( ippcpGetEnabledNumThreads() )
-#define IPPCP_OMP_NUM_THREADS() num_threads( IPPCP_GET_NUM_THREADS() )
-#define IPPCP_OMP_LIMIT_MAX_NUM_THREADS(n) num_threads( IPP_MIN(IPPCP_GET_NUM_THREADS(),(n)))
-
-/* copy under mask */
-#define MASKED_COPY_BNU(dst, mask, src1, src2, len) { \
- cpSize i; \
- for(i=0; i<(len); i++) (dst)[i] = ((mask) & (src1)[i]) | (~(mask) & (src2)[i]); \
-}
-
-#endif /* __OWNCP_H__ */
diff --git a/ext/ipp/sources/ippcp/src/pcpbnca.c b/ext/ipp/sources/ippcp/src/pcpbnca.c
deleted file mode 100644
index 0173d21..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnca.c
+++ /dev/null
@@ -1,1297 +0,0 @@
-/*############################################################################
- # Copyright 2002-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives (ippcp)
-//
-// Contents:
-// ippsBigNumGetSize()
-// ippsBigNumInit()
-//
-// ippsSet_BN()
-// ippsGet_BN()
-// ippsGetSize_BN()
-// ippsExtGet_BN()
-// ippsRef_BN()
-//
-// ippsCmpZero_BN()
-// ippsCmp_BN()
-//
-// ippsAdd_BN()
-// ippsSub_BN()
-// ippsMul_BN()
-// ippsMAC_BN_I()
-// ippsDiv_BN()
-// ippsMod_BN()
-// ippsGcd_BN()
-// ippsModInv_BN()
-//
-// cpPackBigNumCtx(), cpUnpackBigNumCtx()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcptool.h"
-
-/* BN(1) and reference */
-static IppsBigNumStateChunk cpChunk_BN1 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN1.value,&cpChunk_BN1.temporary
- },
- 1,0
-};
-
-#define cpBN_OneRef OWNAPI(cpBN_OneRef)
-IppsBigNumState* cpBN_OneRef(void)
-{ return &cpChunk_BN1.bn; };
-
-/* BN(2) and reference */
-static IppsBigNumStateChunk cpChunk_BN2 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN2.value,&cpChunk_BN2.temporary
- },
- 2,0
-};
-#define cpBN_TwoRef OWNAPI(cpBN_TwoRef)
-IppsBigNumState* cpBN_TwoRef(void)
-{ return &cpChunk_BN2.bn; };
-
-/* BN(3) and reference */
-static IppsBigNumStateChunk cpChunk_BN3 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN3.value,&cpChunk_BN3.temporary
- },
- 3,0
-};
-#define cpBN_ThreeRef OWNAPI(cpBN_ThreeRef)
-IppsBigNumState* cpBN_ThreeRef(void)
-{ return &cpChunk_BN3.bn; };
-
-
-
-/*F*
-// Name: ippsBigNumGetSize
-//
-// Purpose: Returns size of BigNum ctx (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtxSize == NULL
-// ippStsLengthErr len32 < 1
-// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtxSize pointer BigNum ctx size
-//
-*F*/
-IPPFUN(IppStatus, ippsBigNumGetSize, (cpSize len32, cpSize *pCtxSize))
-{
- IPP_BAD_PTR1_RET(pCtxSize);
- IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- {
- /* convert length to the number of BNU_CHUNK_T */
- cpSize len = INTERNAL_BNU_LENGTH(len32);
-
- /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
- mul, mont exp operations */
- len++;
-
- *pCtxSize = sizeof(IppsBigNumState)
- + len*sizeof(BNU_CHUNK_T)
- + len*sizeof(BNU_CHUNK_T)
- + BN_ALIGNMENT-1;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsBigNumInit
-//
-// Purpose: Init BigNum spec for future usage.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// ippStsLengthErr len32<1
-// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// len32 max BN length (32-bits segments)
-// pBN BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsBigNumInit, (cpSize len32, IppsBigNumState* pBN))
-{
- IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
- IPP_BAD_PTR1_RET(pBN);
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
-
- {
- Ipp8u* ptr = (Ipp8u*)pBN;
-
- /* convert length to the number of BNU_CHUNK_T */
- cpSize len = INTERNAL_BNU_LENGTH(len32);
-
- BN_ID(pBN) = idCtxUnknown;
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1; /* initial valie is zero */
- BN_ROOM(pBN) = len; /* close to what has been passed by user */
-
- /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
- mul, mont exp operations */
- len++;
-
- /* allocate buffers */
- BN_NUMBER(pBN) = (BNU_CHUNK_T*)(ptr += sizeof(IppsBigNumState));
- BN_BUFFER(pBN) = (BNU_CHUNK_T*)(ptr += len*sizeof(BNU_CHUNK_T)); /* use expanded length here */
-
- /* set BN value and buffer to zero */
- ZEXPAND_BNU(BN_NUMBER(pBN), 0, len);
- ZEXPAND_BNU(BN_BUFFER(pBN), 0, len);
-
- BN_ID(pBN) = idCtxBigNum;
- return ippStsNoErr;
- }
-}
-
-/*
-// Serialize / Deserialize bigNum context
-*/
-void cpPackBigNumCtx(const IppsBigNumState* pBN, Ipp8u* pBuffer)
-{
- IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT));
- CopyBlock(pBN, pAlignedBuffer, sizeof(IppsBigNumState));
- BN_NUMBER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_NUMBER(pBN))-IPP_UINT_PTR(pBN));
- BN_BUFFER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_BUFFER(pBN))-IPP_UINT_PTR(pBN));
- CopyBlock(BN_NUMBER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
- CopyBlock(BN_BUFFER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
-}
-
-void cpUnpackBigNumCtx(const Ipp8u* pBuffer, IppsBigNumState* pBN)
-{
- IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT));
- CopyBlock(pBuffer, pBN, sizeof(IppsBigNumState));
- BN_NUMBER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)));
- BN_BUFFER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)));
- CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_NUMBER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
- CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_BUFFER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T));
-}
-
-
-/*F*
-// Name: ippsCmpZero_BN
-//
-// Purpose: Test BigNum value.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pResult == NULL
-// ippStsContextMatchErr BN_VALID_ID()
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBN BigNum ctx
-// pResult result of comparison
-//
-*F*/
-IPPFUN(IppStatus, ippsCmpZero_BN, (const IppsBigNumState* pBN, Ipp32u* pResult))
-{
- IPP_BAD_PTR2_RET(pBN, pResult);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- if(BN_SIZE(pBN)==1 && BN_NUMBER(pBN)[0]==0)
- *pResult = IS_ZERO;
- else if (BN_SIGN(pBN)==ippBigNumPOS)
- *pResult = GREATER_THAN_ZERO;
- else if (BN_SIGN(pBN)==ippBigNumNEG)
- *pResult = LESS_THAN_ZERO;
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsCmp_BN
-//
-// Purpose: Compare two BigNums.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pResult == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA BigNum ctx
-// pB BigNum ctx
-// pResult result of comparison
-//
-*F*/
-IPPFUN(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u *pResult))
-{
- IPP_BAD_PTR3_RET(pA, pB, pResult);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
-
- {
- int res;
- if(BN_SIGN(pA)==BN_SIGN(pB)) {
- res = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB));
- if(ippBigNumNEG==BN_SIGN(pA))
- res = -res;
- }
- else
- res = (ippBigNumPOS==BN_SIGN(pA))? 1 :-1;
-
- *pResult = (1==res)? IPP_IS_GT : (-1==res)? IPP_IS_LT : IPP_IS_EQ;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsGetSize_BN
-//
-// Purpose: Returns BigNum room.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pSize == NULL
-// ippStsContextMatchErr BN_VALID_ID(pBN)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBN BigNum ctx
-// pSize max BigNum length (in Ipp32u chunks)
-//
-*F*/
-IPPFUN(IppStatus, ippsGetSize_BN, (const IppsBigNumState* pBN, cpSize* pSize))
-{
- IPP_BAD_PTR2_RET(pBN, pSize);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- *pSize = BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsSet_BN
-//
-// Purpose: Set BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pData == NULL
-// ippStsContextMatchErr BN_VALID_ID(pBN)
-// ippStsLengthErr len32 < 1
-// ippStsOutOfRangeErr len32 > BN_ROOM()
-// ippStsNoErr no errors
-//
-// Parameters:
-// sgn sign
-// len32 data size (in Ipp32u chunks)
-// pData source data pointer
-// pBn BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsSet_BN, (IppsBigNumSGN sgn, cpSize len32, const Ipp32u* pData,
- IppsBigNumState* pBN))
-{
- IPP_BAD_PTR2_RET(pData, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- IPP_BADARG_RET(len32<1, ippStsLengthErr);
-
- /* compute real size */
- FIX_BNU(pData, len32);
-
- {
- cpSize len = INTERNAL_BNU_LENGTH(len32);
- IPP_BADARG_RET(len > BN_ROOM(pBN), ippStsOutOfRangeErr);
-
- ZEXPAND_COPY_BNU((Ipp32u*)BN_NUMBER(pBN), BN_ROOM(pBN)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pData, len32);
-
- BN_SIZE(pBN) = len;
-
- if(len32==1 && pData[0] == 0)
- sgn = ippBigNumPOS; /* consider zero value as positive */
- BN_SIGN(pBN) = sgn;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsGet_BN
-//
-// Purpose: Get BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pData == NULL
-// pSgn == NULL
-// pLen32 ==NULL
-// ippStsContextMatchErr !BN_VALID_ID(pBN)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSgn pointer to the sign
-// pLen32 pointer to the data size (in Ipp32u chunks)
-// pData pointer to the data buffer
-// pBN BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsGet_BN, (IppsBigNumSGN* pSgn, cpSize* pLen32, Ipp32u* pData,
- const IppsBigNumState* pBN))
-{
- IPP_BAD_PTR4_RET(pSgn, pLen32, pData, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- {
- cpSize len32 = BN_SIZE(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
- Ipp32u* bnData = (Ipp32u*)BN_NUMBER(pBN);
-
- FIX_BNU(bnData, len32);
- COPY_BNU(pData, bnData, len32);
-
- *pSgn = BN_SIGN(pBN);
- *pLen32 = len32;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsRef_BN
-//
-// Purpose: Get BigNum info.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// ippStsContextMatchErr BN_VALID_ID(pBN)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSgn pointer to the sign
-// pBitSize pointer to the data size (in bits)
-// ppData pointer to the data buffer
-// pBN BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsRef_BN, (IppsBigNumSGN* pSgn, cpSize* pBitSize, Ipp32u** const ppData,
- const IppsBigNumState *pBN))
-{
- IPP_BAD_PTR1_RET(pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- if(pSgn)
- *pSgn = BN_SIGN(pBN);
- if(pBitSize) {
- cpSize bitLen = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN));
- *pBitSize = bitLen? bitLen : 1;
- }
-
- if(ppData)
- *ppData = (Ipp32u*)BN_NUMBER(pBN);
-
- return ippStsNoErr;
-}
-
-
-IPPFUN(IppStatus, ippsExtGet_BN, (IppsBigNumSGN* pSgn, cpSize* pBitSize, Ipp32u* pData,
- const IppsBigNumState* pBN))
-{
- IPP_BAD_PTR1_RET(pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- {
- cpSize bitSize = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN));
- if(0==bitSize)
- bitSize = 1;
- if(pData)
- COPY_BNU(pData, (Ipp32u*)BN_NUMBER(pBN), BITS2WORD32_SIZE(bitSize));
- if(pSgn)
- *pSgn = BN_SIGN(pBN);
- if(pBitSize)
- *pBitSize = bitSize;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsAdd_BN
-//
-// Purpose: Add BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
- IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- IppsBigNumSGN sgnA = BN_SIGN(pA);
- IppsBigNumSGN sgnB = BN_SIGN(pB);
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
-
- BNU_CHUNK_T carry;
-
- if(sgnA==sgnB) {
- if(nsA < nsB) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
- if(carry) {
- if(nsR>nsA)
- pDataR[nsA++] = carry;
- else
- IPP_ERROR_RET(ippStsOutOfRangeErr);
- }
- BN_SIGN(pR) = sgnA;
- }
-
- else {
- int cmpRes = cpCmp_BNU(pDataA, nsA, pDataB, nsB);
-
- if(0==cmpRes) {
- pDataR[0] = 0;
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = ippBigNumPOS;
- return ippStsNoErr;
- }
-
- if(0>cmpRes) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
-
- BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
- }
-
- FIX_BNU(pDataR, nsA);
- BN_SIZE(pR) = nsA;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsSub_BN
-//
-// Purpose: Subtcrac BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
- IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- IppsBigNumSGN sgnA = BN_SIGN(pA);
- IppsBigNumSGN sgnB = BN_SIGN(pB);
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
-
- BNU_CHUNK_T carry;
-
- if(sgnA!=sgnB) {
- if(nsA < nsB) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
- if(carry) {
- if(nsR > nsA)
- pDataR[nsA++] = carry;
- else
- IPP_ERROR_RET(ippStsOutOfRangeErr);
- }
- BN_SIGN(pR) = sgnA;
- }
-
- else {
- int cmpRes= cpCmp_BNU(pDataA, nsA, pDataB, nsB);
-
- if(0==cmpRes) {
- ZEXPAND_BNU(pDataR,0, nsR);
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = ippBigNumPOS;
- return ippStsNoErr;
- }
-
- if(0>cmpRes) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
-
- BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
- }
-
- FIX_BNU(pDataR, nsA);
- BN_SIZE(pR) = nsA;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsMul_BN
-//
-// Purpose: Multiply BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
-
- cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA);
- cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB);
-
- /* test if multiplicant/multiplier is zero */
- if(!bitSizeA || !bitSizeB) {
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = IppsBigNumPOS;
- pDataR[0] = 0;
- return ippStsNoErr;
- }
-
- /* test if even low estimation of product A*B exceeded */
- IPP_BADARG_RET(nsR*BNU_CHUNK_BITS < (bitSizeA+bitSizeB-1), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* aData = pDataA;
- BNU_CHUNK_T* bData = pDataB;
-
- if(pA == pR) {
- aData = BN_BUFFER(pR);
- COPY_BNU(aData, pDataA, nsA);
- }
- if((pB == pR) && (pA != pB)) {
- bData = BN_BUFFER(pR);
- COPY_BNU(bData, pDataB, nsB);
- }
-
- /* clear result */
- ZEXPAND_BNU(pDataR, 0, nsR+1);
-
- if(pA==pB)
- cpSqr_BNU_school(pDataR, aData, nsA);
- else
- cpMul_BNU_school(pDataR, aData, nsA, bData, nsB);
-
- nsR = (bitSizeA + bitSizeB + BNU_CHUNK_BITS - 1) /BNU_CHUNK_BITS;
- FIX_BNU(pDataR, nsR);
- IPP_BADARG_RET(nsR>BN_ROOM(pR), ippStsOutOfRangeErr);
-
- BN_SIZE(pR) = nsR;
- BN_SIGN(pR) = (BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG);
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsMAC_BN_I
-//
-// Purpose: Multiply and Accumulate BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not fit result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsMAC_BN_I, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
-
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
-
- cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA);
- cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB);
- /* size of temporary pruduct */
- cpSize nsP = BITS_BNU_CHUNK(bitSizeA+bitSizeB);
-
- /* test if multiplicant/multiplier is zero */
- if(!bitSizeA || !bitSizeB) return ippStsNoErr;
- /* test if product can't fit to the result */
- IPP_BADARG_RET(BN_ROOM(pR)<nsP, ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
- IppsBigNumSGN sgnR = BN_SIGN(pR);
- cpSize nsR = BN_SIZE(pR);
- cpSize room = BN_ROOM(pR);
-
- /* temporary product */
- BNU_CHUNK_T* pDataP = BN_BUFFER(pR);
- IppsBigNumSGN sgnP = BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG;
-
- /* clear the rest of R data buffer */
- ZEXPAND_BNU(pDataR, nsR, room);
-
- /* temporary product */
- if(pA==pB)
- cpSqr_BNU_school(pDataP, pDataA, nsA);
- else
- cpMul_BNU_school(pDataP, pDataA, nsA, pDataB, nsB);
- /* clear the rest of rpoduct */
- ZEXPAND_BNU(pDataP, nsP, room);
-
- if(sgnR==sgnP) {
- BNU_CHUNK_T carry = cpAdd_BNU(pDataR, pDataR, pDataP, room);
- if(carry) {
- BN_SIZE(pR) = room;
- IPP_ERROR_RET(ippStsOutOfRangeErr);
- }
- }
-
- else {
- BNU_CHUNK_T* pTmp = pDataR;
- int cmpRes = cpCmp_BNU(pDataR, room, pDataP, room);
- if(0>cmpRes) {
- SWAP_PTR(BNU_CHUNK_T, pTmp, pDataP);
- }
- cpSub_BNU(pDataR, pTmp, pDataP, room);
-
- BN_SIGN(pR) = cmpRes>0? sgnR : INVERSE_SIGN(sgnR);
- }
-
- FIX_BNU(pDataR, room);
- BN_SIZE(pR) = room;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsDiv_BN
-//
-// Purpose: Divide BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pQ == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pQ)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pQ and/or pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pQ quotient BigNum
-// pR reminder BigNum
-//
-// A = Q*B + R, 0 <= val(R) < val(B), sgn(A)==sgn(R)
-//
-*F*/
-IPPFUN(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR))
-{
- IPP_BAD_PTR4_RET(pA, pB, pQ, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pQ, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pQ), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_SIZE(pB)== 1 && BN_NUMBER(pB)[0]==0, ippStsDivByZeroErr);
-
- IPP_BADARG_RET(BN_ROOM(pR)<BN_SIZE(pB), ippStsOutOfRangeErr);
- IPP_BADARG_RET((int)BN_ROOM(pQ)<(int)(BN_SIZE(pA)-BN_SIZE(pB)), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataA = BN_BUFFER(pA);
- cpSize nsA = BN_SIZE(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
- cpSize nsB = BN_SIZE(pB);
- BNU_CHUNK_T* pDataQ = BN_NUMBER(pQ);
- cpSize nsQ;
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
- cpSize nsR;
-
- COPY_BNU(pDataA, BN_NUMBER(pA), nsA);
- nsR = cpDiv_BNU(pDataQ, &nsQ, pDataA, nsA, pDataB, nsB);
- COPY_BNU(pDataR, pDataA, nsR);
-
- BN_SIGN(pQ) = BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG;
- BN_SIZE(pQ) = nsQ;
- if(nsQ==1 && pDataQ[0]==0) BN_SIGN(pQ) = ippBigNumPOS;
-
- BN_SIGN(pR) = BN_SIGN(pA);
- BN_SIZE(pR) = nsR;
- if(nsR==1 && pDataR[0]==0) BN_SIGN(pR) = ippBigNumPOS;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsMod_BN
-//
-// Purpose: reduction BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pM == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pM)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR reminder BigNum
-//
-// A = Q*M + R, 0 <= R < B
-//
-*F*/
-IPPFUN(IppStatus, ippsMod_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pM, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_NEGATIVE(pM), ippStsBadModulusErr);
- IPP_BADARG_RET(BN_SIZE(pM)== 1 && BN_NUMBER(pM)[0]==0, ippStsBadModulusErr);
-
- IPP_BADARG_RET(BN_ROOM(pR)<BN_SIZE(pM), ippStsOutOfRangeErr);
-
- if(cpEqu_BNU_CHUNK(BN_NUMBER(pA), BN_SIZE(pA), 0)) {
- BN_SIGN(pR) = ippBigNumPOS;
- BN_SIZE(pR) = 1;
- BN_NUMBER(pR)[0] = 0;
- }
-
- else {
- BNU_CHUNK_T* pDataM = BN_NUMBER(pM);
- cpSize nsM = BN_SIZE(pM);
- BNU_CHUNK_T* pBuffA = BN_BUFFER(pA);
- cpSize nsA = BN_SIZE(pA);
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
- cpSize nsR;
-
- COPY_BNU(pBuffA, BN_NUMBER(pA), nsA);
- nsR = cpMod_BNU(pBuffA, nsA, pDataM, nsM);
-
- COPY_BNU(pDataR, pBuffA, nsR);
- BN_SIZE(pR) = nsR;
- BN_SIGN(pR) = ippBigNumPOS;
-
- if(BN_NEGATIVE(pA) && !(nsR==1 && pDataR[0]==0)) {
- ZEXPAND_BNU(pDataR, nsR, nsM);
- cpSub_BNU(pDataR, pDataM, pDataR, nsM);
- FIX_BNU(pDataR, nsM);
- BN_SIZE(pR) = nsM;
- }
- }
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsGcd_BN
-//
-// Purpose: compute GCD value.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pG == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pG)
-// ippStsBadArgErr A==B==0
-// ippStsOutOfRangeErr pG can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pG GCD value
-//
-*F*/
-IPPFUN(IppStatus, ippsGcd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pG))
-{
- IPP_BAD_PTR3_RET(pA, pB, pG);
-
- pA = (IppsBigNumState*)(IPP_ALIGNED_PTR(pA, BN_ALIGNMENT));
- pB = (IppsBigNumState*)(IPP_ALIGNED_PTR(pB, BN_ALIGNMENT));
- pG = (IppsBigNumState*)(IPP_ALIGNED_PTR(pG, BN_ALIGNMENT));
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pG), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_ROOM(pG) < IPP_MIN(BN_SIZE(pA), BN_SIZE(pB)), ippStsOutOfRangeErr);
-
- {
- IppsBigNumState* x = pA;
- IppsBigNumState* y = pB;
- IppsBigNumState* g = pG;
-
- int aIsZero = BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0;
- int bIsZero = BN_SIZE(pB)==1 && BN_NUMBER(pB)[0]==0;
-
- if(aIsZero && bIsZero)
- return ippStsBadArgErr;
- if(aIsZero && !bIsZero) {
- COPY_BNU(BN_NUMBER(g), BN_NUMBER(pB), BN_SIZE(pB));
- BN_SIZE(g) = BN_SIZE(pB);
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
- if(bIsZero && !aIsZero) {
- COPY_BNU(BN_NUMBER(g), BN_NUMBER(pA), BN_SIZE(pA));
- BN_SIZE(g) = BN_SIZE(pA);
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
-
- /*
- // Lehmer's algorithm requres that first number must be greater than second
- // x is the first, y is the second
- */
- {
- int cmpRes = cpCmp_BNU(BN_NUMBER(x), BN_SIZE(x), BN_NUMBER(y), BN_SIZE(y));
- if(0>cmpRes)
- SWAP_PTR(IppsBigNumState, x, y);
- if(0==cmpRes) {
- COPY_BNU(BN_NUMBER(g), BN_NUMBER(x), BN_SIZE(x));
- BN_SIGN(g) = ippBigNumPOS;
- BN_SIZE(g) = BN_SIZE(x);
- return ippStsNoErr;
- }
- if(BN_SIZE(x)==1) {
- BNU_CHUNK_T gcd = cpGcd_BNU(BN_NUMBER(x)[0], BN_NUMBER(y)[0]);
- BN_NUMBER(g)[0] = gcd;
- BN_SIZE(g) = 1;
- return ippStsNoErr;
- }
- }
-
- {
- Ipp32u* xBuffer = (Ipp32u*)BN_BUFFER(x);
- Ipp32u* yBuffer = (Ipp32u*)BN_BUFFER(y);
- Ipp32u* gBuffer = (Ipp32u*)BN_BUFFER(g);
- Ipp32u* xData = (Ipp32u*)BN_NUMBER(x);
- Ipp32u* yData = (Ipp32u*)BN_NUMBER(y);
- Ipp32u* gData = (Ipp32u*)BN_NUMBER(g);
- cpSize nsXmax = BN_ROOM(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsYmax = BN_ROOM(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsGmax = BN_ROOM(g)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsX = BN_SIZE(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsY = BN_SIZE(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
-
- Ipp32u* T;
- Ipp32u* u;
-
- FIX_BNU(xData, nsX);
- FIX_BNU(yData, nsY);
-
- /* init buffers */
- ZEXPAND_COPY_BNU(xBuffer, nsXmax, xData, nsX);
- ZEXPAND_COPY_BNU(yBuffer, nsYmax, yData, nsY);
-
- T = gBuffer;
- u = gData;
- ZEXPAND_BNU(T, 0, nsGmax);
- ZEXPAND_BNU(u, 0, nsGmax);
-
- while(nsX > (cpSize)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
- /* xx and yy is the high-order digits of x and y (yy could be 0) */
-
- Ipp64u xx = (Ipp64u)(xBuffer[nsX-1]);
- Ipp64u yy = (nsY < nsX)? 0 : (Ipp64u)(yBuffer[nsY-1]);
-
- Ipp64s AA = 1;
- Ipp64s BB = 0;
- Ipp64s CC = 0;
- Ipp64s DD = 1;
- Ipp64s t;
-
- while((yy+CC)!=0 && (yy+DD)!=0) {
- Ipp64u q = ( xx + AA ) / ( yy + CC );
- Ipp64u q1 = ( xx + BB ) / ( yy + DD );
- if(q!=q1)
- break;
- t = AA - q*CC;
- AA = CC;
- CC = t;
- t = BB - q*DD;
- BB = DD;
- DD = t;
- t = xx - q*yy;
- xx = yy;
- yy = t;
- }
-
- if(BB == 0) {
- /* T = x mod y */
- cpSize nsT = cpMod_BNU32(xBuffer, nsX, yBuffer, nsY);
- ZEXPAND_BNU(T, 0, nsGmax);
- COPY_BNU(T, xBuffer, nsT);
- /* a = b; b = T; */
- ZEXPAND_BNU(xBuffer, 0, nsXmax);
- COPY_BNU(xBuffer, yBuffer, nsY);
- ZEXPAND_BNU(yBuffer, 0, nsYmax);
- COPY_BNU(yBuffer, T, nsY);
- }
-
- else {
- Ipp32u carry;
- /*
- // T = AA*x + BB*y;
- // u = CC*x + DD*y;
- // b = u; a = T;
- */
- if((AA <= 0)&&(BB>=0)) {
- Ipp32u a1 = (Ipp32u)(-AA);
- carry = cpMulDgt_BNU32(T, yBuffer, nsY, (Ipp32u)BB);
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, a1);
- /* T = BB*y - AA*x; */
- carry = cpSub_BNU32(T, T, u, nsY);
- }
- else {
- if((AA >= 0)&&(BB<=0)) {
- Ipp32u b1 = (Ipp32u)(-BB);
- carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, b1);
- /* T = AA*x - BB*y; */
- carry = cpSub_BNU32(T, T, u, nsY);
- }
- else {
- /*AA*BB>=0 */
- carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)BB);
- /* T = AA*x + BB*y; */
- carry = cpAdd_BNU32(T, T, u, nsY);
- }
- }
-
- /* Now T is reserved. We use only u for intermediate results. */
- if((CC <= 0)&&(DD>=0)){
- Ipp32u c1 = (Ipp32u)(-CC);
- /* u = x*CC; x = u; */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, c1);
- COPY_BNU(xBuffer, u, nsY);
- /* u = y*DD; */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
- /* u = DD*y - CC*x; */
- carry = cpSub_BNU32(u, u, xBuffer, nsY);
- }
- else {
- if((CC >= 0)&&(DD<=0)){
- Ipp32u d1 = (Ipp32u)(-DD);
- /* u = y*DD; y = u */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, d1);
- COPY_BNU(yBuffer, u, nsY);
- /* u = CC*x; */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
- /* u = CC*x - DD*y; */
- carry = cpSub_BNU32(u, u, yBuffer, nsY);
- }
- else {
- /*CC*DD>=0 */
- /* y = y*DD */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
- COPY_BNU(yBuffer, u, nsY);
- /* u = x*CC */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
- /* u = x*CC + y*DD */
- carry = cpAdd_BNU32(u, u, yBuffer, nsY);
- }
- }
-
- /* y = u; x = T; */
- COPY_BNU(yBuffer, u, nsY);
- COPY_BNU(xBuffer, T, nsY);
- }
-
- FIX_BNU(xBuffer, nsX);
- FIX_BNU(yBuffer, nsY);
-
- if (nsY > nsX) {
- SWAP_PTR(IppsBigNumState, x, y);
- SWAP(nsX, nsY);
- }
-
- if (nsY==1 && yBuffer[nsY-1]==0) {
- /* End evaluation */
- ZEXPAND_BNU(gData, 0, nsGmax);
- COPY_BNU(gData, xBuffer, nsX);
- BN_SIZE(g) = INTERNAL_BNU_LENGTH(nsX);
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
- }
-
- BN_NUMBER(g)[0] = cpGcd_BNU(((BNU_CHUNK_T*)xBuffer)[0], ((BNU_CHUNK_T*)yBuffer)[0]);
- BN_SIZE(g) = 1;
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsModInv_BN
-//
-// Purpose: Multiplicative Inversion BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pM == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pM)
-// BN_VALID_ID(pR)
-// ippStsBadArgErr A<=0
-// ippStsBadModulusErr M<=0
-// ippStsScaleRangeErr A>=M
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-// ippStsBadModulusErr inversion not found
-//
-// Parameters:
-// pA source (value) BigNum
-// pM source (modulus) BigNum
-// pR reminder BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsModInv_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR) )
-{
- IPP_BAD_PTR3_RET(pA, pM, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_ROOM(pR) < BN_SIZE(pM), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pA) || (BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0), ippStsBadArgErr);
- IPP_BADARG_RET(BN_NEGATIVE(pM) || (BN_SIZE(pM)==1 && BN_NUMBER(pM)[0]==0), ippStsBadModulusErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pM), BN_SIZE(pM)) >= 0, ippStsScaleRangeErr);
-
- {
- cpSize nsR = cpModInv_BNU(BN_NUMBER(pR),
- BN_NUMBER(pA), BN_SIZE(pA),
- BN_NUMBER(pM), BN_SIZE(pM),
- BN_BUFFER(pR), BN_BUFFER(pA), BN_BUFFER(pM));
- if(nsR) {
- BN_SIGN(pR) = ippBigNumPOS;
- BN_SIZE(pR) = nsR;
- return ippStsNoErr;
- }
- else
- return ippStsBadModulusErr;
- }
-}
-
diff --git a/ext/ipp/sources/ippcp/src/pcpbnsetca.c b/ext/ipp/sources/ippcp/src/pcpbnsetca.c
deleted file mode 100644
index 4fb060e..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnsetca.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*############################################################################
- # Copyright 2004-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Big Number Operations
-//
-// Contents:
-// ippsSetOctString_BN()
-// ippsGetOctString_BN()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-
-
-/*F*
-// Name: ippsSetOctString_BN
-//
-// Purpose: Convert octet string into the BN value.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pOctStr
-// NULL == pBN
-//
-// ippStsLengthErr 0>strLen
-//
-// ippStsSizeErr BN_ROOM() is enough for keep actual strLen
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pOctStr pointer to the source octet string
-// strLen octet string length
-// pBN pointer to the target BN
-//
-*F*/
-IPPFUN(IppStatus, ippsSetOctString_BN,(const Ipp8u* pOctStr, cpSize strLen,
- IppsBigNumState* pBN))
-{
- IPP_BAD_PTR2_RET(pOctStr, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- IPP_BADARG_RET((0>strLen), ippStsLengthErr);
-
- /* remove leading zeros */
- while(strLen && (0==pOctStr[0])) {
- strLen--;
- pOctStr++;
- }
-
- /* test BN size */
- IPP_BADARG_RET((int)(sizeof(BNU_CHUNK_T)*BN_ROOM(pBN))<strLen, ippStsSizeErr);
- if(strLen)
- BN_SIZE(pBN) = cpFromOctStr_BNU(BN_NUMBER(pBN), pOctStr, strLen);
- else {
- BN_NUMBER(pBN)[0] = (BNU_CHUNK_T)0;
- BN_SIZE(pBN) = 1;
- }
- BN_SIGN(pBN) = ippBigNumPOS;
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsGetOctString_BN
-//
-// Purpose: Convert BN value into the octet string.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pOctStr
-// NULL == pBN
-//
-// ippStsRangeErr BN <0
-//
-// ippStsLengthErr strLen is enough for keep BN value
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBN pointer to the source BN
-// pOctStr pointer to the target octet string
-// strLen octet string length
-*F*/
-IPPFUN(IppStatus, ippsGetOctString_BN,(Ipp8u* pOctStr, cpSize strLen,
- const IppsBigNumState* pBN))
-{
- IPP_BAD_PTR2_RET(pOctStr, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pBN), ippStsRangeErr);
- IPP_BADARG_RET((0>strLen), ippStsLengthErr);
-
- return cpToOctStr_BNU(pOctStr,strLen, BN_NUMBER(pBN),BN_SIZE(pBN))? ippStsNoErr : ippStsLengthErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpbnu32arith.c b/ext/ipp/sources/ippcp/src/pcpbnu32arith.c
deleted file mode 100644
index f64a8f3..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnu32arith.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*############################################################################
- # Copyright 2002-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
-// Internal BNU32 arithmetic.
-//
-// Contents:
-//
-// cpAdd_BNU32()
-// cpSub_BNU32()
-//
-// cpMulDgt_BNU32()
-// cpSubMulDgt_BNU32()
-//
-// cpDiv_BNU32()
-//
-//
-*/
-
-#include "owncp.h"
-#include "pcpbnumisc.h"
-#include "pcpbnu32misc.h"
-#include "pcpbnu32arith.h"
-
-/*
-// BNU32 addition
-*/
-Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns)
-{
- Ipp32u carry = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- Ipp64u t = (Ipp64u)carry +pA[i] + pB[i];
- pR[i] = LODWORD(t);
- carry = HIDWORD(t);
- }
- return carry;
-}
-
-/*
-// BNU32 subtraction
-*/
-Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns)
-{
- Ipp32u borrow = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- Ipp64u t = (Ipp64u)(pA[i]) - pB[i] - borrow;
- pR[i] = LODWORD(t);
- borrow = 0-HIDWORD(t);
- }
- return borrow;
-}
-
-/*
-// BNU32 increment
-*/
-Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u v)
-{
- Ipp32u carry = v;
- cpSize i;
- for(i=0; i<ns && carry; i++) {
- Ipp64u t = (Ipp64u)carry +pA[i];
- pR[i] = LODWORD(t);
- carry = HIDWORD(t);
- }
- return carry;
-}
-
-/*
-// BNU32 decrement
-*/
-Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u v)
-{
- Ipp32u borrow = v;
- int n;
- for(n=0; n<ns; n++) {
- Ipp64u t = (Ipp64u)(pA[n]) - (Ipp64u)borrow;
- pR[n] = LODWORD(t);
- borrow = HIDWORD(t)>>(32-1);
- }
- return borrow;
-}
-
-/*
-// BNU32 mul_by_digit
-*/
-Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)
-{
- Ipp32u carry = 0;
- cpSize i;
- for(i=0; i<nsA; i++) {
- Ipp64u t = (Ipp64u)val * (Ipp64u)pA[i] + carry;
- pR[i] = LODWORD(t);
- carry = HIDWORD(t);
- }
- return carry;
-}
-
-/*
-// BNU32 mul_by_digit_subtract
-*/
-#if !((_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
-Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)
-{
- Ipp32u carry = 0;
- for(; nsA>0; nsA--) {
- Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry;
- *pR++ = LODWORD(r);
- carry = 0-HIDWORD(r);
- }
- return carry;
-}
-#endif
-
-/*
-// BNU32 division
-*/
-#if !((_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
-int cpDiv_BNU32(Ipp32u* pQ, cpSize* sizeQ,
- Ipp32u* pX, cpSize sizeX,
- Ipp32u* pY, cpSize sizeY)
-{
- FIX_BNU(pY,sizeY);
- FIX_BNU(pX,sizeX);
-
- /* special case */
- if(sizeX < sizeY) {
-
- if(pQ) {
- pQ[0] = 0;
- *sizeQ = 1;
- }
-
- return sizeX;
- }
-
- /* special case */
- if(1 == sizeY) {
- int i;
- Ipp32u r = 0;
- for(i=(int)sizeX-1; i>=0; i--) {
- Ipp64u tmp = MAKEDWORD(pX[i],r);
- Ipp32u q = LODWORD(tmp / pY[0]);
- r = LODWORD(tmp - q*pY[0]);
- if(pQ) pQ[i] = q;
- }
-
- pX[0] = r;
-
- if(pQ) {
- FIX_BNU(pQ,sizeX);
- *sizeQ = sizeX;
- }
-
- return 1;
- }
-
-
- /* common case */
- {
- cpSize qs = sizeX-sizeY+1;
-
- cpSize nlz = cpNLZ_BNU32(pY[sizeY-1]);
-
- /* normalization */
- pX[sizeX] = 0;
- if(nlz) {
- cpSize ni;
-
- pX[sizeX] = pX[sizeX-1] >> (32-nlz);
- for(ni=sizeX-1; ni>0; ni--)
- pX[ni] = (pX[ni]<<nlz) | (pX[ni-1]>>(32-nlz));
- pX[0] <<= nlz;
-
- for(ni=sizeY-1; ni>0; ni--)
- pY[ni] = (pY[ni]<<nlz) | (pY[ni-1]>>(32-nlz));
- pY[0] <<= nlz;
- }
-
- /*
- // division
- */
- {
- Ipp32u yHi = pY[sizeY-1];
-
- int i;
- for(i=(int)qs-1; i>=0; i--) {
- Ipp32u extend;
-
- /* estimate digit of quotient */
- Ipp64u tmp = MAKEDWORD(pX[i+sizeY-1], pX[i+sizeY]);
- Ipp64u q = tmp / yHi;
- Ipp64u r = tmp - q*yHi;
-
- /* tune estimation above */
- //for(; (q>=CONST_64(0x100000000)) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) {
- for(; HIDWORD(q) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) {
- q -= 1;
- r += yHi;
- if( HIDWORD(r) )
- break;
- }
-
- /* multiply and subtract */
- extend = cpSubMulDgt_BNU32(pX+i, pY, sizeY, (Ipp32u)q);
- extend = (pX[i+sizeY] -= extend);
-
- if(extend) { /* subtracted too much */
- q -= 1;
- extend = cpAdd_BNU32(pX+i, pY, pX+i, sizeY);
- pX[i+sizeY] += extend;
- }
-
- /* store quotation digit */
- if(pQ) pQ[i] = LODWORD(q);
- }
- }
-
- /* de-normalization */
- if(nlz) {
- cpSize ni;
- for(ni=0; ni<sizeX; ni++)
- pX[ni] = (pX[ni]>>nlz) | (pX[ni+1]<<(32-nlz));
- for(ni=0; ni<sizeY-1; ni++)
- pY[ni] = (pY[ni]>>nlz) | (pY[ni+1]<<(32-nlz));
- pY[sizeY-1] >>= nlz;
- }
-
- FIX_BNU(pX,sizeX);
-
- if(pQ) {
- FIX_BNU(pQ,qs);
- *sizeQ = qs;
- }
-
- return sizeX;
- }
-}
-#endif
-
-#define FE_MUL(R,A,B,LEN) { \
- int aidx, bidx; \
- \
- for(aidx=0; aidx<(LEN); aidx++) (R)[aidx] = 0; \
- \
- for(bidx=0; bidx<(LEN); bidx++) { \
- Ipp64u b = (B)[bidx]; \
- Ipp32u c = 0; \
- for(aidx=0; aidx<(LEN); aidx++) { \
- Ipp64u t = (R)[bidx+aidx] + (A)[aidx] * b + c; \
- (R)[bidx+aidx] = LODWORD(t); \
- c = HIDWORD(t); \
- } \
- (R)[bidx+aidx] = c; \
- } \
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpbnu32arith.h b/ext/ipp/sources/ippcp/src/pcpbnu32arith.h
deleted file mode 100644
index 9d4c0c1..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnu32arith.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*############################################################################
- # Copyright 2012-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives.
-// Internal BNU32 arithmetic
-//
-//
-*/
-
-#if !defined(_CP_BNU32_ARITH_H)
-#define _CP_BNU32_ARITH_H
-
-#define cpAdd_BNU32 OWNAPI(cpAdd_BNU32)
-Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
-#define cpSub_BNU32 OWNAPI(cpSub_BNU32)
-Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
-#define cpInc_BNU32 OWNAPI(cpInc_BNU32)
-Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
-#define cpDec_BNU32 OWNAPI(cpDec_BNU32)
-Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
-
-#define cpMulDgt_BNU32 OWNAPI(cpMulDgt_BNU32)
-Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int ns, Ipp32u val);
-#define cpSubMulDgt_BNU32 OWNAPI(cpSubMulDgt_BNU32)
-Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int nsA, Ipp32u val);
-
-#define cpDiv_BNU32 OWNAPI(cpDiv_BNU32)
-int cpDiv_BNU32(Ipp32u* pQ, int* nsQ, Ipp32u* pX, int nsX, Ipp32u* pY, int nsY);
-#define cpMod_BNU32(pX,sizeX, pM,sizeM) cpDiv_BNU32(NULL,NULL, (pX),(sizeX), (pM),(sizeM))
-
-#define cpFromOS_BNU32 OWNAPI(cpFromOS_BNU32)
-int cpFromOS_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, int strLen);
-#define cpToOS_BNU32 OWNAPI(cpToOS_BNU32)
-int cpToOS_BNU32(Ipp8u* pStr, int strLen, const Ipp32u* pBNU, int bnuSize);
-
-#endif /* _CP_BNU32_ARITH_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpbnu32misc.c b/ext/ipp/sources/ippcp/src/pcpbnu32misc.c
deleted file mode 100644
index 157b9b1..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnu32misc.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
-// Unsigned internal BNU32 misc functionality
-//
-// Contents:
-// cpNLZ_BNU32()
-// cpNTZ_BNU32()
-//
-// cpLSL_BNU32()
-// cpLSR_BNU32()
-//
-// cpFromOctStr_BNU32()
-// cpToOctStr_BNU32()
-//
-//
-*/
-
-#include "owncp.h"
-#include "pcpbnuimpl.h"
-#include "pcpbnumisc.h"
-#include "pcpbnu32misc.h"
-
-
-/*
-// number of leading zeros
-*/
-cpSize cpNLZ_BNU32(Ipp32u x)
-{
- cpSize nlz = BITSIZE(Ipp32u);
- if(x) {
- nlz = 0;
- if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x80000000) ) { nlz++; }
- }
- return nlz;
-}
-
-/*
-// Convert Oct String into BNU representation
-//
-// Returns length of BNU in Ipp32u chunks
-*/
-cpSize cpFromOctStr_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, cpSize strLen)
-{
- cpSize bnuSize=0;
- *pBNU = 0;
-
- /* start from the end of string */
- for(; strLen>=4; bnuSize++,strLen-=4) {
- /* pack 4 bytes into single Ipp32u value*/
- *pBNU++ = ( pOctStr[strLen-4]<<(8*3) )
- +( pOctStr[strLen-3]<<(8*2) )
- +( pOctStr[strLen-2]<<(8*1) )
- + pOctStr[strLen-1];
- }
-
- /* convert the beginning of the string */
- if(strLen) {
- Ipp32u x;
- for(x=0; strLen>0; strLen--) {
- Ipp32u d = *pOctStr++;
- x = x*256 + d;
- }
- *pBNU++ = x;
- bnuSize++;
- }
-
- return bnuSize? bnuSize : 1;
-}
-
-
-/*
-// Convert BNU into Octet String representation
-//
-// Returns strLen or 0 if no success
-*/
-cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize)
-{
- FIX_BNU(pBNU, bnuSize);
- {
- int bnuBitSize = BITSIZE_BNU32(pBNU, bnuSize);
- if(bnuBitSize <= strLen*BYTESIZE) {
- Ipp32u x = pBNU[bnuSize-1];
-
- ZEXPAND_BNU(pStr, 0, strLen);
- pStr += strLen - BITS2WORD8_SIZE(bnuBitSize);
-
- if(x) {
- int nb;
- for(nb=cpNLZ_BNU32(x)/BYTESIZE; nb<4; nb++)
- *pStr++ = EBYTE(x,3-nb);
-
- for(--bnuSize; bnuSize>0; bnuSize--) {
- x = pBNU[bnuSize-1];
- *pStr++ = EBYTE(x,3);
- *pStr++ = EBYTE(x,2);
- *pStr++ = EBYTE(x,1);
- *pStr++ = EBYTE(x,0);
- }
- }
- return strLen;
- }
- else
- return 0;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpbnu32misc.h b/ext/ipp/sources/ippcp/src/pcpbnu32misc.h
deleted file mode 100644
index 6cc4523..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnu32misc.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
-// Internal Miscellaneous BNU 32 bit Definitions & Function Prototypes
-//
-//
-*/
-
-#if !defined(_CP_BNU32_MISC_H)
-#define _CP_BNU32_MISC_H
-
-
-/* bit operations */
-#define BITSIZE_BNU32(p,ns) ((ns)*BNU_CHUNK_32BIT-cpNLZ_BNU32((p)[(ns)-1]))
-
-/* number of leading/trailing zeros */
-#define cpNLZ_BNU32 OWNAPI(cpNLZ_BNU32)
-cpSize cpNLZ_BNU32(Ipp32u x);
-
-/* most significant BNU bit */
-__INLINE int cpMSBit_BNU32(const Ipp32u* pA, cpSize nsA)
-{
- FIX_BNU(pA, nsA);
- return nsA*BITSIZE(Ipp32u) - cpNLZ_BNU32(pA[nsA-1]) -1;
-}
-
-
-__INLINE int cpCmp_BNU32(const Ipp32u* pA, cpSize nsA, const Ipp32u* pB, cpSize nsB)
-{
- if(nsA!=nsB)
- return nsA>nsB? 1 : -1;
- else {
- for(; nsA>0; nsA--) {
- if(pA[nsA-1] > pB[nsA-1])
- return 1;
- else if(pA[nsA-1] < pB[nsA-1])
- return -1;
- }
- return 0;
- }
-}
-
-/* to/from oct string conversion */
-#define cpToOctStr_BNU32 OWNAPI(cpToOctStr_BNU32)
-cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize);
-#define cpFromOctStr_BNU32 OWNAPI(cpFromOctStr_BNU32)
-cpSize cpFromOctStr_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, cpSize strLen);
-
-#endif /* _CP_BNU32_MISC_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpbnuarith.c b/ext/ipp/sources/ippcp/src/pcpbnuarith.c
deleted file mode 100644
index 8f8b245..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnuarith.c
+++ /dev/null
@@ -1,538 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
-// Internal Unsigned arithmetic
-//
-// Contents:
-// cpAdd_BNU()
-// cpSub_BNU()
-// cpInc_BNU()
-// cpDec_BNU()
-//
-// cpAddAdd_BNU()
-// cpAddSub_BNU()
-//
-// cpMuldgt_BNU()
-// cpAddMulDgt_BNU()
-// cpSubMulDgt_BNU()
-//
-// cpMulAdc_BNU_school()
-// cpSqrAdc_BNU_school()
-//
-// cpDiv_BNU()
-// cpMod_BNU()
-// cpGcd_BNU()
-// cpModInv_BNU()
-//
-//
-*/
-
-#include "owncp.h"
-#include "pcpbnuarith.h"
-#include "pcpbnumisc.h"
-
-
-/* Function cpAdd_BNU - addition of 2 BNU */
-#if defined(_USE_C_cpAdd_BNU_)
-#pragma message ("C version of cpAdd_BNU: ON")
-#else
-//#pragma message ("C version of cpAdd_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8) || \
- (_IPPLRB>=_IPPLRB_B1)) || \
- defined(_USE_C_cpAdd_BNU_)
-BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns)
-{
- BNU_CHUNK_T carry = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- ADD_ABC(carry, pR[i], pA[i],pB[i], carry);
- }
- return carry;
-}
-#endif
-
-/* Function cpSub_BNU - subtraction of 2 BNU */
-#if defined(_USE_C_cpSub_BNU_)
-#pragma message ("C version of cpSub_BNU: ON")
-#else
-//#pragma message ("C version of cpSub_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8) || \
- (_IPPLRB>=_IPPLRB_B1)) || \
- defined(_USE_C_cpSub_BNU_)
-BNU_CHUNK_T cpSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns)
-{
- BNU_CHUNK_T borrow = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- SUB_ABC(borrow, pR[i], pA[i], pB[i], borrow);
- }
- return borrow;
-}
-#endif
-
-/* Function cpInc_BNU - increment BNU */
-#if defined(_USE_C_cpInc_BNU_)
-#pragma message ("C version of cpInc_BNU: ON")
-#else
-//#pragma message ("C version of cpInc_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8)) || \
- defined(_USE_C_cpInc_BNU_)
-BNU_CHUNK_T cpInc_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
-{
- cpSize i;
- for(i=0; i<ns && val; i++) {
- BNU_CHUNK_T carry;
- ADD_AB(carry, pR[i], pA[i], val);
- val = carry;
- }
- if(pR!=pA)
- for(; i<ns; i++)
- pR[i] = pA[i];
- return val;
-}
-#endif
-
-#if !((_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
-BNU_CHUNK_T cpDec_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
-{
- cpSize i;
- for(i=0; i<ns && val; i++) {
- BNU_CHUNK_T borrow;
- SUB_AB(borrow, pR[i], pA[i], val);
- val = borrow;
- }
- if(pR!=pA)
- for(; i<ns; i++)
- pR[i] = pA[i];
- return val;
-}
-#endif
-
-/* Function cpAddAdd_BNU */
-#if defined(_USE_KARATSUBA_)
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
-BNU_CHUNK_T cpAddAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize ns)
-{
- BNU_CHUNK_T carry1 = 0;
- BNU_CHUNK_T carry2 = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- BNU_CHUNK_T s;
- ADD_ABC(carry1, s, pA[i],pB[i],carry1);
- ADD_ABC(carry2, pR[i], s,pC[i],carry2);
- }
- return (carry1+carry2);
-}
-#endif
-#endif
-
-/* Function cpAddSub_BNU */
-#if defined(_USE_KARATSUBA_)
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
-BNU_CHUNK_T cpAddSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize ns)
-{
- BNU_CHUNK_T carry = 0;
- BNU_CHUNK_T borrow = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- BNU_CHUNK_T d;
- SUB_ABC(borrow, d, pB[i], pC[i], borrow);
- ADD_ABC(carry, pR[i], d, pA[i], carry);
- }
- return (carry-borrow);
-}
-#endif
-#endif
-
-
-/* Function cpAddMulDgt_BNU - multiply-and-add BNU */
-#if defined(_USE_C_cpAddMulDgt_BNU_)
-#pragma message ("C version of cpAddMulDgt_BNU: ON")
-#else
-//#pragma message ("C version of cpAddMulDgt_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8)) || \
- defined(_USE_C_cpAddMulDgt_BNU_)
-BNU_CHUNK_T cpAddMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
-{
- BNU_CHUNK_T extension = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- BNU_CHUNK_T rH, rL;
-
- MUL_AB(rH, rL, pA[i], val);
- ADD_ABC(extension, pR[i], pR[i], rL, extension);
- extension += rH;
- }
- return extension;
-}
-#endif
-
-
-/* Function cpSubMulDgt_BNU - multiply-and-sub BNU */
-#if defined(_USE_C_cpSubMulDgt_BNU_)
-#pragma message ("C version of cpSubMulDgt_BNU: ON")
-#else
-//#pragma message ("C version of cpSubMulDgt_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8) || \
- (_IPPLRB >= _IPPLRB_B1)) || \
- defined(_USE_C_cpSubMulDgt_BNU_)
-BNU_CHUNK_T cpSubMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val)
-{
- BNU_CHUNK_T extension = 0;
- cpSize i;
- for(i=0; i<ns; i++) {
- BNU_CHUNK_T rH, rL;
-
- MUL_AB(rH, rL, pA[i], val);
- SUB_ABC(extension, pR[i], pR[i], rL, extension);
- extension += rH;
- }
- return extension;
-}
-#endif
-
-
-/* Function cpMulAdc_BNU_school - multiply BNU */
-#if defined(_USE_C_cpMulAdc_BNU_school_)
-#pragma message ("C version of cpMulAdc_BNU_school: ON")
-#else
-//#pragma message ("C version of cpMulAdc_BNU_school: OFF")
-#endif
-
-#if !((_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8)) || \
- defined(_USE_C_cpMulAdc_BNU_school_)
-BNU_CHUNK_T cpMulAdc_BNU_school(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pA, cpSize nsA,
- const BNU_CHUNK_T* pB, cpSize nsB)
-{
- const BNU_CHUNK_T* pa = (BNU_CHUNK_T*)pA;
- const BNU_CHUNK_T* pb = (BNU_CHUNK_T*)pB;
- BNU_CHUNK_T* pr = (BNU_CHUNK_T*)pR;
-
- BNU_CHUNK_T extension = 0;
- cpSize i, j;
-
- ZEXPAND_BNU(pr, 0, nsA+nsB);
-
- for(i=0; i<nsB; i++ ) {
- BNU_CHUNK_T b = pb[i];
-
- for(j=0, extension=0; j<nsA; j++ ) {
- BNU_CHUNK_T rH, rL;
-
- MUL_AB(rH, rL, pa[j], b);
- ADD_ABC(extension, pr[i+j], pr[i+j], rL, extension);
- extension += rH;
- }
- pr[i+j] = extension;
- }
- return extension;
-}
-#endif
-
-
-/* Function cpSqrAdc_BNU_school - sqr BNU */
-#if defined(_USE_C_cpSqrAdc_BNU_school_)
-#pragma message ("C version of cpSqrAdc_BNU_school: ON")
-#else
-//#pragma message ("C version of cpSqrAdc_BNU_school: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8)) || \
- defined(_USE_C_cpSqrAdc_BNU_school_)
-BNU_CHUNK_T cpSqrAdc_BNU_school(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA)
-{
- cpSize i;
-
- BNU_CHUNK_T extension;
- BNU_CHUNK_T rH, rL;
-
- /* init result */
- pR[0] = 0;
- for(i=1, extension=0; i<nsA; i++) {
- MUL_AB(rH, rL, pA[i], pA[0]);
- ADD_AB(extension, pR[i], rL, extension);
- extension += rH;
- }
- pR[i] = extension;
-
- /* add other a[i]*a[j] */
- for(i=1; i<nsA-1; i++) {
- BNU_CHUNK_T a = pA[i];
- cpSize j;
- for(j=i+1, extension=0; j<nsA; j++) {
- MUL_AB(rH, rL, pA[j], a);
- ADD_ABC(extension, pR[i+j], rL, pR[i+j], extension);
- extension += rH;
- }
- pR[i+j] = extension;
- }
-
- /* double a[i]*a[j] */
- for(i=1, extension=0; i<(2*nsA-1); i++) {
- ADD_ABC(extension, pR[i], pR[i], pR[i], extension);
- }
- pR[i] = extension;
-
- /* add a[i]^2 */
- for(i=0, extension=0; i<nsA; i++) {
- MUL_AB(rH, rL, pA[i], pA[i]);
- ADD_ABC(extension, pR[2*i], pR[2*i], rL, extension);
- ADD_ABC(extension, pR[2*i+1], pR[2*i+1], rH, extension);
- }
- return pR[2*nsA-1];
-}
-#endif
-
-
-BNU_CHUNK_T cpGcd_BNU(BNU_CHUNK_T a, BNU_CHUNK_T b)
-{
- BNU_CHUNK_T gcd, t, r;
-
- if(a > b){
- gcd = a;
- t = b;
- } else {
- t = a;
- gcd = b;
- }
-
- while (t != 0) {
- r = gcd % t;
- gcd = t;
- t = r;
- }
- return gcd;
-}
-
-/*
-// cpMAC_BNU
-//
-// Multiply with ACcumulation
-// Computes r <- r + a * b, returns real size of the r in the size_r variable
-// Returns 0 if there are no enought buffer size to write to r[MAX(size_r + 1, size_a + size_b) - 1]
-// Returns 1 if no error
-//
-// Note:
-// DO NOT run in inplace mode
-// The minimum buffer size for the r must be (size_a + size_b - 1)
-// the maximum buffer size for the r is MAX(size_r + 1, size_a + size_b)
-*/
-static int cpMac_BNU(BNU_CHUNK_T* pR, cpSize nsR,
- const BNU_CHUNK_T* pA, cpSize nsA,
- const BNU_CHUNK_T* pB, cpSize nsB)
-{
- /* cleanup the rest of destination buffer */
- ZEXPAND_BNU(pR, nsR, nsA+nsB-1);
- //nsR = IPP_MAX(nsR, nsA+nsB);
-
- {
- BNU_CHUNK_T expansion = 0;
- cpSize i;
- for(i=0; i<nsB && !expansion; i++) {
- expansion = cpAddMulDgt_BNU(pR+i, pA, nsA, pB[i]);
- if(expansion)
- expansion = cpInc_BNU(pR+i+nsA, pR+i+nsA, nsR-i-nsA, expansion);
- }
-
- if(expansion)
- return 0;
- else { /* compute real size */
- FIX_BNU(pR, nsR);
- return nsR;
- }
- }
-}
-
-int cpModInv_BNU(BNU_CHUNK_T* pInv,
- const BNU_CHUNK_T* pA, cpSize nsA,
- const BNU_CHUNK_T* pM, cpSize nsM,
- BNU_CHUNK_T* bufInv, BNU_CHUNK_T* bufA, BNU_CHUNK_T* bufM)
-{
- FIX_BNU(pA, nsA);
- FIX_BNU(pM, nsM);
-
- /* inv(1) = 1 */
- if(nsA==1 && pA[0]==1) {
- pInv[0] = 1;
- return 1;
- }
-
- {
- cpSize moduloSize = nsM;
-
- BNU_CHUNK_T* X1 = pInv;
- BNU_CHUNK_T* X2 = bufM;
- BNU_CHUNK_T* Q = bufInv;
- cpSize nsX1 = 1;
- cpSize nsX2 = 1;
- cpSize nsQ;
-
- COPY_BNU(bufA, pA, nsA);
-
- ZEXPAND_BNU(X1, 0, moduloSize);
- ZEXPAND_BNU(X2, 0, moduloSize);
- X2[0] = 1;
-
- //printf("\n");
- for(;;) {
- nsM = cpDiv_BNU(Q, &nsQ, (BNU_CHUNK_T*)pM, nsM, bufA, nsA);
- //Print_BNU(" q: ", Q, nsQ);
- //Print_BNU(" m: ", pM, nsM);
- nsX1 = cpMac_BNU(X1,moduloSize, Q,nsQ, X2,nsX2);
- //Print_BNU("X1: ", X1, nsX1);
-
- if (nsM==1 && pM[0]==1) {
- ////ZEXPAND_BNU(X2, nsX2, moduloSize);
- nsX2 = cpMac_BNU(X2,moduloSize, X1,nsX1, bufA, nsA);
- COPY_BNU((BNU_CHUNK_T*)pM, X2, moduloSize);
- cpSub_BNU(pInv, pM, X1, moduloSize);
- FIX_BNU(pInv, moduloSize);
- return moduloSize;
- }
- else if (nsM==1 && pM[0]==0) {
- cpMul_BNU_school((BNU_CHUNK_T*)pM, X1,nsX1, bufA, nsA);
- /* gcd = buf_a */
- return 0;
- }
-
- nsA = cpDiv_BNU(Q, &nsQ, bufA, nsA, (BNU_CHUNK_T*)pM, nsM);
- //Print_BNU(" q: ", Q, nsQ);
- //Print_BNU(" a: ", bufA, nsA);
- nsX2 = cpMac_BNU(X2,moduloSize, Q,nsQ, X1,nsX1);
- //Print_BNU("X2: ", X2, nsX2);
-
- if(nsA==1 && bufA[0]==1) {
- ////ZEXPAND_BNU(X1, nsX1, moduloSize);
- nsX1 = cpMac_BNU(X1, moduloSize, X2, nsX2, pM, nsM);
- COPY_BNU((BNU_CHUNK_T*)pM, X1, moduloSize);
- COPY_BNU(pInv, X2, nsX2);
- return nsX2;
- }
- else if (nsA==1 && bufA[0]==0) {
- /* gcd = m */
- COPY_BNU(X1, pM, nsM);
- cpMul_BNU_school((BNU_CHUNK_T*)pM, X2, nsX2, X1, nsM);
- return 0;
- }
- }
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpbnumisc.c b/ext/ipp/sources/ippcp/src/pcpbnumisc.c
deleted file mode 100644
index 7bd840b..0000000
--- a/ext/ipp/sources/ippcp/src/pcpbnumisc.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives. Cryptography Primitives.
-// Internal Unsigned BNU misc functionality
-//
-// Contents:
-// cpNLZ_BNU()
-// cpNTZ_BNU()
-//
-// cpLSL_BNU()
-// cpLSR_BNU()
-//
-// cpLSBit_BNU()
-// cpMSBit_BNU()
-//
-// cpFromOctStr_BNU()
-// cpToOctStrS_BNU()
-//
-//
-*/
-
-#include "owncp.h"
-#include "pcpbnumisc.h"
-
-
-/*
-// number of leading zeros
-*/
-cpSize cpNLZ_BNU(BNU_CHUNK_T x)
-{
- cpSize nlz = BNU_CHUNK_BITS;
- if(x) {
- nlz = 0;
- #if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT)
- if( 0==(x & 0xFFFFFFFF00000000) ) { nlz +=32; x<<=32; }
- if( 0==(x & 0xFFFF000000000000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF00000000000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF000000000000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC000000000000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x8000000000000000) ) { nlz++; }
- #else
- if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x80000000) ) { nlz++; }
- #endif
- }
- return nlz;
-}
-
-/*
-// number of trailing zeros
-*/
-cpSize cpNTZ_BNU(BNU_CHUNK_T x)
-{
- cpSize ntz = BNU_CHUNK_BITS;
- if(x) {
- ntz = 0;
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- if( 0==(x & 0x00000000FFFFFFFF) ) { ntz+=32; x>>=32; }
- if( 0==(x & 0x000000000000FFFF) ) { ntz+=16; x>>=16; }
- if( 0==(x & 0x00000000000000FF) ) { ntz+= 8; x>>= 8; }
- if( 0==(x & 0x000000000000000F) ) { ntz+= 4; x>>= 4; }
- if( 0==(x & 0x0000000000000003) ) { ntz+= 2; x>>= 2; }
- if( 0==(x & 0x0000000000000001) ) { ntz++; }
- #else
- if( 0==(x & 0x0000FFFF) ) { ntz+=16; x>>=16; }
- if( 0==(x & 0x000000FF) ) { ntz+= 8; x>>= 8; }
- if( 0==(x & 0x0000000F) ) { ntz+= 4; x>>= 4; }
- if( 0==(x & 0x00000003) ) { ntz+= 2; x>>= 2; }
- if( 0==(x & 0x00000001) ) { ntz++; }
- #endif
- }
- return ntz;
-}
-
-/*
-// Logical shift right (including inplace)
-//
-// Returns new length
-//
-*/
-cpSize cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits)
-{
- cpSize nw = nBits/BNU_CHUNK_BITS;
- cpSize n;
-
- pA += nw;
- nsA -= nw;
-
- nBits %= BNU_CHUNK_BITS;
- if(nBits) {
- BNU_CHUNK_T hi;
- BNU_CHUNK_T lo = pA[0];
-
- for(n=0; n<(nsA-1); n++) {
- hi = pA[n+1];
- pR[n] = (lo>>nBits) | (hi<<(BNU_CHUNK_BITS-nBits));
- lo = hi;
- }
- pR[nsA-1] = (lo>>nBits);
- }
- else {
- for(n=0; n<nsA; n++)
- pR[n] = pA[n];
- }
-
- for(n=0; n<nw; n++)
- pR[nsA+n] = 0;
-
- return nsA+nw;
-}
-
-/*
-// Returns Most Significant Bit of the BNU
-// Note:
-// if BNU==0, -1 will return
-*/
-int cpMSBit_BNU(const BNU_CHUNK_T* pA, cpSize nsA)
-{
- int msb;
- FIX_BNU(pA, nsA);
- msb = nsA*BNU_CHUNK_BITS - cpNLZ_BNU(pA[nsA-1]) -1;
- return msb;
-}
-
-/*
-// Convert Oct String into BNU representation
-//
-// Returns size of BNU in BNU_CHUNK_T chunks
-*/
-cpSize cpFromOctStr_BNU(BNU_CHUNK_T* pA, const Ipp8u* pStr, cpSize strLen)
-{
- int nsA =0;
-
- /* start from the end of string */
- for(; strLen>=(int)sizeof(BNU_CHUNK_T); nsA++,strLen-=(int)(sizeof(BNU_CHUNK_T))) {
- /* pack sizeof(BNU_CHUNK_T) bytes into single BNU_CHUNK_T value*/
- *pA++ =
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- +( (BNU_CHUNK_T)pStr[strLen-8]<<(8*7) )
- +( (BNU_CHUNK_T)pStr[strLen-7]<<(8*6) )
- +( (BNU_CHUNK_T)pStr[strLen-6]<<(8*5) )
- +( (BNU_CHUNK_T)pStr[strLen-5]<<(8*4) )
- #endif
- +( (BNU_CHUNK_T)pStr[strLen-4]<<(8*3) )
- +( (BNU_CHUNK_T)pStr[strLen-3]<<(8*2) )
- +( (BNU_CHUNK_T)pStr[strLen-2]<<(8*1) )
- + (BNU_CHUNK_T)pStr[strLen-1];
- }
-
- /* convert the beginning of the string */
- if(strLen) {
- BNU_CHUNK_T x = 0;
- for(x=0; strLen>0; strLen--) {
- BNU_CHUNK_T d = *pStr++;
- x = (x<<8) + d;
- }
- *pA++ = x;
- nsA++;
- }
-
- return nsA;
-}
-
-/*
-// Convert BNU into HexString representation
-//
-// Returns length of the string or 0 if no success
-*/
-cpSize cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA)
-{
- FIX_BNU(pA, nsA);
- {
- cpSize bnuBitSize = BITSIZE_BNU(pA, nsA);
- if(bnuBitSize <= strLen*BYTESIZE) {
- int cnvLen = 0;
- BNU_CHUNK_T x = pA[nsA-1];
-
- ZEXPAND_BNU(pStr, 0, strLen);
- pStr += strLen - BITS2WORD8_SIZE(bnuBitSize);
-
- if(x) {
- //int nb;
- cpSize nb;
- for(nb=cpNLZ_BNU(x)/BYTESIZE; nb<(cpSize)(sizeof(BNU_CHUNK_T)); cnvLen++, nb++)
- *pStr++ = EBYTE(x, sizeof(BNU_CHUNK_T)-1-nb);
-
- for(--nsA; nsA>0; cnvLen+=sizeof(BNU_CHUNK_T), nsA--) {
- x = pA[nsA-1];
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- *pStr++ = EBYTE(x,7);
- *pStr++ = EBYTE(x,6);
- *pStr++ = EBYTE(x,5);
- *pStr++ = EBYTE(x,4);
- #endif
- *pStr++ = EBYTE(x,3);
- *pStr++ = EBYTE(x,2);
- *pStr++ = EBYTE(x,1);
- *pStr++ = EBYTE(x,0);
- }
- }
- return strLen;
- }
- else
- return 0;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp128r1r2dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp128r1r2dpca.c
deleted file mode 100644
index e04d137..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp128r1r2dpca.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd128r1()
-// ippsECCPSetStd128r2()
-*/
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC128r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd128r1, (IppsECCPState* pEC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(128), secp128r1_p,
- BITS_BNU_CHUNK(128), secp128r1_a,
- BITS_BNU_CHUNK(128), secp128r1_b,
- BITS_BNU_CHUNK(128), secp128r1_gx,
- BITS_BNU_CHUNK(128), secp128r1_gy,
- BITS_BNU_CHUNK(128), secp128r1_r,
- secp128r1_h,
- pEC);
-}
-
-
-/*
-// Set EC128r2 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd128r2, (IppsECCPState* pEC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(128), secp128r2_p,
- BITS_BNU_CHUNK(128), secp128r2_a,
- BITS_BNU_CHUNK(128), secp128r2_b,
- BITS_BNU_CHUNK(128), secp128r2_gx,
- BITS_BNU_CHUNK(128), secp128r2_gy,
- BITS_BNU_CHUNK(128), secp128r2_r,
- secp128r2_h,
- pEC);
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp192r1dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp192r1dpca.c
deleted file mode 100644
index 7e3510c..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp192r1dpca.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd192r1()
-*/
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC192r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd192r1, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p192r1(),
- BITS_BNU_CHUNK(192), secp192r1_p,
- BITS_BNU_CHUNK(192), secp192r1_a,
- BITS_BNU_CHUNK(192), secp192r1_b,
- BITS_BNU_CHUNK(192), secp192r1_gx,
- BITS_BNU_CHUNK(192), secp192r1_gy,
- BITS_BNU_CHUNK(192), secp192r1_r,
- secp192r1_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStd192r1,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_nistP192r1_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp224r1dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp224r1dpca.c
deleted file mode 100644
index c497be9..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp224r1dpca.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd224r1()
-*/
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC224r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd224r1, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsECCPState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p224r1(),
- BITS_BNU_CHUNK(224), secp224r1_p,
- BITS_BNU_CHUNK(224), secp224r1_a,
- BITS_BNU_CHUNK(224), secp224r1_b,
- BITS_BNU_CHUNK(224), secp224r1_gx,
- BITS_BNU_CHUNK(224), secp224r1_gy,
- BITS_BNU_CHUNK(224), secp224r1_r,
- secp224r1_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStd224r1,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_nistP224r1_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp256r1dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp256r1dpca.c
deleted file mode 100644
index 9d380dc..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp256r1dpca.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd256r1()
-*/
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC256r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd256r1, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p256r1(),
- BITS_BNU_CHUNK(256), secp256r1_p,
- BITS_BNU_CHUNK(256), secp256r1_a,
- BITS_BNU_CHUNK(256), secp256r1_b,
- BITS_BNU_CHUNK(256), secp256r1_gx,
- BITS_BNU_CHUNK(256), secp256r1_gy,
- BITS_BNU_CHUNK(256), secp256r1_r,
- secp256r1_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStd256r1,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_nistP256r1_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp384r1dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp384r1dpca.c
deleted file mode 100644
index 4082b3c..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp384r1dpca.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd384r1()
-*/
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC384r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd384r1, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p384r1(),
- BITS_BNU_CHUNK(384), secp384r1_p,
- BITS_BNU_CHUNK(384), secp384r1_a,
- BITS_BNU_CHUNK(384), secp384r1_b,
- BITS_BNU_CHUNK(384), secp384r1_gx,
- BITS_BNU_CHUNK(384), secp384r1_gy,
- BITS_BNU_CHUNK(384), secp384r1_r,
- secp384r1_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStd384r1,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_nistP384r1_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccp521r1dpca.c b/ext/ipp/sources/ippcp/src/pcpeccp521r1dpca.c
deleted file mode 100644
index 9c9f3bf..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccp521r1dpca.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStd521r1()
-*/
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set EC521r1 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStd521r1, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p521r1(),
- BITS_BNU_CHUNK(521), secp521r1_p,
- BITS_BNU_CHUNK(521), secp521r1_a,
- BITS_BNU_CHUNK(521), secp521r1_b,
- BITS_BNU_CHUNK(521), secp521r1_gx,
- BITS_BNU_CHUNK(521), secp521r1_gy,
- BITS_BNU_CHUNK(521), secp521r1_r,
- secp521r1_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStd521r1,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_nistP521r1_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpdpca.c b/ext/ipp/sources/ippcp/src/pcpeccpdpca.c
deleted file mode 100644
index 8010137..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccpdpca.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSet()
-// ippsECCPSetStd()
-// ippsECCPSetStd128r1()
-// ippsECCPSetStd128r2()
-// ippsECCPSetStd192r1()
-// ippsECCPSetStd224r1()
-// ippsECCPSetStd256r1()
-// ippsECCPSetStd384r1()
-// ippsECCPSetStd521r1()
-// ippsECCPSetStdSM2()
-//
-// ippsECCPGet()
-// ippsECCPGetBitSizeOrder()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsECCPSet
-//
-// Purpose: Set EC Domain Parameters.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPrime
-// NULL == pA
-// NULL == pB
-// NULL == pGX
-// NULL == pGY
-// NULL == pOrder
-// NULL == pECC
-//
-// ippStsContextMatchErr illegal pPrime->idCtx
-// illegal pA->idCtx
-// illegal pB->idCtx
-// illegal pGX->idCtx
-// illegal pGY->idCtx
-// illegal pOrder->idCtx
-// illegal pECC->idCtx
-//
-// ippStsRangeErr not enough room for:
-// pPrime
-// pA, pB,
-// pGX,pGY
-// pOrder
-//
-// ippStsRangeErr 0>= cofactor
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrime pointer to the prime (specify FG(p))
-// pA pointer to the A coefficient of EC equation
-// pB pointer to the B coefficient of EC equation
-// pGX,pGY pointer to the Base Point (x and y coordinates) of EC
-// pOrder pointer to the Base Point order
-// cofactor cofactor value
-// pECC pointer to the ECC context
-//
-*F*/
-IppStatus ECCPSetDP(const IppsGFpMethod* method,
- int pLen, const BNU_CHUNK_T* pP,
- int aLen, const BNU_CHUNK_T* pA,
- int bLen, const BNU_CHUNK_T* pB,
- int xLen, const BNU_CHUNK_T* pX,
- int yLen, const BNU_CHUNK_T* pY,
- int rLen, const BNU_CHUNK_T* pR,
- BNU_CHUNK_T h,
- IppsGFpECState* pEC)
-{
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- {
- IppsGFpState * pGF = ECP_GFP(pEC);
-
- IppStatus sts = ippStsNoErr;
- IppsBigNumState P, H;
- int primeBitSize = BITSIZE_BNU(pP, pLen);
- //cpConstructBN(&P, pLen, (BNU_CHUNK_T*)pP, NULL);
- //sts = cpGFpSetGFp(&P, primeBitSize, method, pGF);
- cpGFpSetGFp(pP, primeBitSize, method, pGF);
-
- if(ippStsNoErr==sts) {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- do {
- int elemLen = GFP_FELEN(pGFE);
- IppsGFpElement elmA, elmB;
-
- /* convert A ans B coeffs into GF elements */
- cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
- cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
- sts = ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
- if(ippStsNoErr!=sts) break;
- sts = ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
- if(ippStsNoErr!=sts) break;
- /* and set EC */
- sts = ippsGFpECSet(&elmA, &elmB, pEC);
- if(ippStsNoErr!=sts) break;
-
- /* convert GX ans GY coeffs into GF elements */
- cpConstructBN(&P, rLen, (BNU_CHUNK_T*)pR, NULL);
- cpConstructBN(&H, 1, &h, NULL);
- sts = ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
- if(ippStsNoErr!=sts) break;
- sts = ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
- if(ippStsNoErr!=sts) break;
- /* and init EC subgroup */
- sts = ippsGFpECSetSubgroup(&elmA, &elmB, &P, &H, pEC);
- } while(0);
-
- cpGFpReleasePool(2, pGFE);
- }
-
- return sts;
- }
-}
-
-IPPFUN(IppStatus, ippsECCPSet, (const IppsBigNumState* pPrime,
- const IppsBigNumState* pA, const IppsBigNumState* pB,
- const IppsBigNumState* pGX,const IppsBigNumState* pGY,
- const IppsBigNumState* pOrder, int cofactor,
- IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test pPrime */
- IPP_BAD_PTR1_RET(pPrime);
- pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
- IPP_BADARG_RET((cpBN_bitsize(pPrime)>GFP_FEBITLEN(GFP_PMA(ECP_GFP(pEC)))), ippStsRangeErr);
-
- /* test pA and pB */
- IPP_BAD_PTR2_RET(pA,pB);
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) );
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- //IPP_BADARG_RET((cpBN_bitsize(pA)>GFP_FEBITLEN(ECP_GFP(pEC))), ippStsRangeErr);
- //IPP_BADARG_RET((cpBN_bitsize(pB)>GFP_FEBITLEN(ECP_GFP(pEC))), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pA) || 0<=cpBN_cmp(pA,pPrime), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pB) || 0<=cpBN_cmp(pB,pPrime), ippStsRangeErr);
-
- /* test pG and pGorder pointers */
- IPP_BAD_PTR3_RET(pGX,pGY, pOrder);
- pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) );
- pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) );
- pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
- //IPP_BADARG_RET((cpBN_bitsize(pGX)>GFP_FEBITLEN(ECP_GFP(pEC))), ippStsRangeErr);
- //IPP_BADARG_RET((cpBN_bitsize(pGY)>GFP_FEBITLEN(ECP_GFP(pEC))), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pGX) || 0<=cpBN_cmp(pGX,pPrime), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pGY) || 0<=cpBN_cmp(pGY,pPrime), ippStsRangeErr);
- IPP_BADARG_RET((cpBN_bitsize(pOrder)>ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- /* test cofactor */
- IPP_BADARG_RET(!(0<cofactor), ippStsRangeErr);
-
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BN_SIZE(pPrime), BN_NUMBER(pPrime),
- BN_SIZE(pA), BN_NUMBER(pA),
- BN_SIZE(pB), BN_NUMBER(pB),
- BN_SIZE(pGX), BN_NUMBER(pGX),
- BN_SIZE(pGY), BN_NUMBER(pGY),
- BN_SIZE(pOrder), BN_NUMBER(pOrder),
- (BNU_CHUNK_T)cofactor,
- pEC);
-}
-
-
-/*F*
-// Name: ippsECCPSetStd
-//
-// Purpose: Set Standard ECC Domain Parameter.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-//
-// ippStsECCInvalidFlagErr invalid flag
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// flag specify standard ECC parameter(s) to be setup
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetStd, (IppECCType flag, IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- switch(flag) {
- case IppECCPStd112r1:
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(112), secp112r1_p,
- BITS_BNU_CHUNK(112), secp112r1_a,
- BITS_BNU_CHUNK(112), secp112r1_b,
- BITS_BNU_CHUNK(112), secp112r1_gx,
- BITS_BNU_CHUNK(112), secp112r1_gy,
- BITS_BNU_CHUNK(112), secp112r1_r,
- secp112r1_h, pEC);
-
- case IppECCPStd112r2:
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(112), secp112r2_p,
- BITS_BNU_CHUNK(112), secp112r2_a,
- BITS_BNU_CHUNK(112), secp112r2_b,
- BITS_BNU_CHUNK(112), secp112r2_gx,
- BITS_BNU_CHUNK(112), secp112r2_gy,
- BITS_BNU_CHUNK(112), secp112r2_r,
- secp112r2_h, pEC);
-
- case IppECCPStd128r1: return ippsECCPSetStd128r1(pEC);
-
- case IppECCPStd128r2: return ippsECCPSetStd128r2(pEC);
-
- case IppECCPStd160r1:
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(160), secp160r1_p,
- BITS_BNU_CHUNK(160), secp160r1_a,
- BITS_BNU_CHUNK(160), secp160r1_b,
- BITS_BNU_CHUNK(160), secp160r1_gx,
- BITS_BNU_CHUNK(160), secp160r1_gy,
- BITS_BNU_CHUNK(161), secp160r1_r,
- secp160r1_h, pEC);
-
- case IppECCPStd160r2:
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(160), secp160r2_p,
- BITS_BNU_CHUNK(160), secp160r2_a,
- BITS_BNU_CHUNK(160), secp160r2_b,
- BITS_BNU_CHUNK(160), secp160r2_gx,
- BITS_BNU_CHUNK(160), secp160r2_gy,
- BITS_BNU_CHUNK(161), secp160r2_r,
- secp160r2_h, pEC);
-
- case IppECCPStd192r1: return ippsECCPSetStd192r1(pEC);
-
- case IppECCPStd224r1: return ippsECCPSetStd224r1(pEC);
-
- case IppECCPStd256r1: return ippsECCPSetStd256r1(pEC);
-
- case IppECCPStd384r1: return ippsECCPSetStd384r1(pEC);
-
- case IppECCPStd521r1: return ippsECCPSetStd521r1(pEC);
-
- case ippEC_TPM_BN_P256:
- return ECCPSetDP(ippsGFpMethod_pArb(),
- BITS_BNU_CHUNK(256), tpmBN_p256p_p,
- BITS_BNU_CHUNK(32), tpmBN_p256p_a,
- BITS_BNU_CHUNK(32), tpmBN_p256p_b,
- BITS_BNU_CHUNK(32), tpmBN_p256p_gx,
- BITS_BNU_CHUNK(32), tpmBN_p256p_gy,
- BITS_BNU_CHUNK(256), tpmBN_p256p_r,
- tpmBN_p256p_h, pEC);
-
- case ippECPstdSM2: return ippsECCPSetStdSM2(pEC);
-
- default:
- return ippStsECCInvalidFlagErr;
- }
-}
-
-
-/*F*
-// Name: ippsECCPGet
-//
-// Purpose: Retrieve ECC Domain Parameter.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPrime
-// NULL == pA
-// NULL == pB
-// NULL == pGX
-// NULL == pGY
-// NULL == pOrder
-// NULL == cofactor
-// NULL == pECC
-//
-// ippStsContextMatchErr illegal pPrime->idCtx
-// illegal pA->idCtx
-// illegal pB->idCtx
-// illegal pGX->idCtx
-// illegal pGY->idCtx
-// illegal pOrder->idCtx
-// illegal pECC->idCtx
-//
-// ippStsRangeErr not enough room for:
-// pPrime
-// pA, pB,
-// pGX,pGY
-// pOrder
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrime pointer to the retrieval prime (specify FG(p))
-// pA pointer to the retrieval A coefficient of EC equation
-// pB pointer to the retrieval B coefficient of EC equation
-// pGX,pGY pointer to the retrieval Base Point (x and y coordinates) of EC
-// pOrder pointer to the retrieval Base Point order
-// cofactor pointer to the retrieval cofactor value
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGet, (IppsBigNumState* pPrime,
- IppsBigNumState* pA, IppsBigNumState* pB,
- IppsBigNumState* pGX,IppsBigNumState* pGY,IppsBigNumState* pOrder,
- int* cofactor,
- IppsECCPState* pEC))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* test pECC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- /* test pPrime */
- IPP_BAD_PTR1_RET(pPrime);
- pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pPrime)<GFP_FELEN(pGFE), ippStsRangeErr);
-
- /* test pA and pB */
- IPP_BAD_PTR2_RET(pA,pB);
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) );
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pA)<GFP_FELEN(pGFE), ippStsRangeErr);
- IPP_BADARG_RET(BN_ROOM(pB)<GFP_FELEN(pGFE), ippStsRangeErr);
-
- /* test pG and pGorder pointers */
- IPP_BAD_PTR3_RET(pGX,pGY, pOrder);
- pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) );
- pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) );
- pOrder= (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder,ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pGX)<GFP_FELEN(pGFE), ippStsRangeErr);
- IPP_BADARG_RET(BN_ROOM(pGY)<GFP_FELEN(pGFE), ippStsRangeErr);
- IPP_BADARG_RET((BN_ROOM(pOrder)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- /* test cofactor */
- IPP_BAD_PTR1_RET(cofactor);
-
- {
- mod_decode decode = GFP_METHOD(pGFE)->decode; /* gf decode method */
- BNU_CHUNK_T* tmp = cpGFpGetPool(1, pGFE);
-
- /* retrieve EC parameter */
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)GFP_MODULUS(pGFE), pPrime);
-
- decode(tmp, ECP_A(pEC), pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pA);
- decode(tmp, ECP_B(pEC), pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pB);
-
- decode(tmp, ECP_G(pEC), pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pGX);
- decode(tmp, ECP_G(pEC)+GFP_FELEN(pGFE), pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)tmp, pGY);
-
- {
- gsModEngine* pR = ECP_MONT_R(pEC);
- ippsSet_BN(ippBigNumPOS, MOD_LEN(pR)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), (Ipp32u*)MOD_MODULUS(pR), pOrder);
- }
-
- *cofactor = (int)ECP_COFACTOR(pEC)[0];
-
- cpGFpReleasePool(1, pGFE);
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsECCPGetOrderBitSize
-//
-// Purpose: Retrieve size of Pase Point Order (in bits).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pBitSize
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBitSize pointer to the size of base point order
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pEC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test pBitSize*/
- IPP_BAD_PTR1_RET(pBitSize);
-
- *pBitSize = ECP_ORDBITSIZE(pEC);
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpinitca.c b/ext/ipp/sources/ippcp/src/pcpeccpinitca.c
deleted file mode 100644
index 03e50ba..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccpinitca.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (initialization)
-//
-// Contents:
-// ippsECCPGetSize()
-// ippsECCPGetSizeStd128r1()
-// ippsECCPGetSizeStd128r2()
-// ippsECCPGetSizeStd192r1()
-// ippsECCPGetSizeStd224r1()
-// ippsECCPGetSizeStd256r1()
-// ippsECCPGetSizeStd384r1()
-// ippsECCPGetSizeStd521r1()
-// ippsECCPGetSizeStdSM2()
-//
-// ippsECCPInit()
-// ippsECCPInitStd128r1()
-// ippsECCPInitStd128r2()
-// ippsECCPInitStd192r1()
-// ippsECCPInitStd224r1()
-// ippsECCPInitStd256r1()
-// ippsECCPInitStd384r1()
-// ippsECCPInitStd521r1()
-// ippsECCPInitStdSM2()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsECCPGetSize
-//
-// Purpose: Returns size of ECC context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsSizeErr 2>feBitSize
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pSize pointer to the size of internal ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGetSize, (int feBitSize, int *pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
-
- {
- /* size of GF context */
- //int gfCtxSize = cpGFpGetSize(feBitSize);
- int gfCtxSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
- /* size of EC context */
- int ecCtxSize = cpGFpECGetSize(1, feBitSize);
-
- /* size of EC scratch buffer: 16 points of BITS_BNU_CHUNK(feBitSize)*3 length each */
- int ecScratchBufferSize = 16*(BITS_BNU_CHUNK(feBitSize)*3)*sizeof(BNU_CHUNK_T);
-
- *pSize = ecCtxSize /* EC context */
- +ECGFP_ALIGNMENT
- +gfCtxSize /* GF context */
- +GFP_ALIGNMENT
- +ecScratchBufferSize /* *scratch buffer */
- +ecScratchBufferSize /* should be enough for 2 tables */
- +CACHE_LINE_SIZE;
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsECCPGetSizeStd128r1
-// ippsECCPGetSizeStd128r2
-// ippsECCPGetSizeStd192r1
-// ippsECCPGetSizeStd224r1
-// ippsECCPGetSizeStd256r1
-// ippsECCPGetSizeStd384r1
-// ippsECCPGetSizeStd521r1
-// ippsECCPGetSizeStdSM2
-*F*/
-IPPFUN(IppStatus, ippsECCPGetSizeStd128r1, (int *pSize))
-{
- return ippsECCPGetSize(128, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd128r2, (int *pSize))
-{
- return ippsECCPGetSize(128, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd192r1, (int *pSize))
-{
- return ippsECCPGetSize(192, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd224r1, (int *pSize))
-{
- return ippsECCPGetSize(224, pSize);
-}
-
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd256r1, (int *pSize))
-{
- return ippsECCPGetSize(256, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd384r1, (int *pSize))
-{
- return ippsECCPGetSize(384, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStd521r1, (int *pSize))
-{
- return ippsECCPGetSize(521, pSize);
-}
-
-IPPFUN(IppStatus, ippsECCPGetSizeStdSM2, (int *pSize))
-{
- return ippsECCPGetSize(256, pSize);
-}
-
-
-/*F*
-// Name: ippsECCPInit
-//
-// Purpose: Init ECC context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-//
-// ippStsSizeErr 2>feBitSize
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPInit, (int feBitSize, IppsECCPState* pEC))
-{
- /* test pEC pointer */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsECCPState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
-
- {
- /* size of GF context */
- //int gfCtxSize = cpGFpGetSize(feBitSize);
- int gfCtxSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
- /* size of EC context */
- int ecCtxSize = cpGFpECGetSize(1, feBitSize);
-
- IppsGFpState* pGF = (IppsGFpState*)(IPP_ALIGNED_PTR((Ipp8u*)pEC+ecCtxSize, GFP_ALIGNMENT));
- BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)IPP_ALIGNED_PTR((Ipp8u*)pGF+gfCtxSize, CACHE_LINE_SIZE);
-
- /* set up contexts */
- IppStatus sts;
- do {
- sts = cpGFpInitGFp(feBitSize, pGF);
- if(ippStsNoErr!=sts) break;
- sts = ippsGFpECInit(pGF, NULL, NULL, pEC);
- } while (0);
-
- /* save scratch buffer pointer */
- ECP_SBUFFER(pEC) = pScratchBuffer;
-
- return sts;
- }
-}
-
-/*F*
-// Name: ippsECCPInitStd128r1
-// ippsECCPInitStd128r2
-// ippsECCPInitStd192r1
-// ippsECCPInitStd224r1
-// ippsECCPInitStd256r1
-// ippsECCPInitStd384r1
-// ippsECCPInitStd521r1
-// ippsECCPInitStdSM2
-*F*/
-IPPFUN(IppStatus, ippsECCPInitStd128r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(128, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd128r2, (IppsECCPState* pEC))
-{
- return ippsECCPInit(128, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd192r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(192, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd224r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(224, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd256r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(256, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd384r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(384, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStd521r1, (IppsECCPState* pEC))
-{
- return ippsECCPInit(521, pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPInitStdSM2, (IppsECCPState* pEC))
-{
- return ippsECCPInit(256, pEC);
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccppointca.c b/ext/ipp/sources/ippcp/src/pcpeccppointca.c
deleted file mode 100644
index f2a49f7..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccppointca.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC (prime) Point
-//
-// Contents:
-// ippsECCPPointGetSize()
-// ippsECCPPointInit()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsECCPPointGetSize
-//
-// Purpose: Returns size of EC Point context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSzie
-// ippStsSizeErr 2>feBitSize
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pSize pointer to the size of EC Point context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPPointGetSize, (int feBitSize, int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
-
- {
- int elemLen = BITS_BNU_CHUNK(feBitSize);
- *pSize= sizeof(IppsGFpECPoint)
- +elemLen*sizeof(BNU_CHUNK_T) /* X */
- +elemLen*sizeof(BNU_CHUNK_T) /* Y */
- +elemLen*sizeof(BNU_CHUNK_T);/* Z */
- }
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPPointInit
-//
-// Purpose: Init EC Point context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPoint
-// ippStsSizeErr 2>feBitSize
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pECC pointer to ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPPointInit, (int feBitSize, IppsECCPPointState* pPoint))
-{
- /* test pEC pointer */
- IPP_BAD_PTR1_RET(pPoint);
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
-
- {
- int elemLen = BITS_BNU_CHUNK(feBitSize);
- Ipp8u* ptr = (Ipp8u*)pPoint;
-
- ECP_POINT_ID(pPoint) = idCtxGFPPoint;
- ECP_POINT_FLAGS(pPoint) = 0;
- ECP_POINT_FELEN(pPoint) = elemLen;
- ptr += sizeof(IppsGFpECPoint);
- ECP_POINT_DATA(pPoint) = (BNU_CHUNK_T*)(ptr);
-
- gfec_SetPointAtInfinity(pPoint);
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccppointopca.c b/ext/ipp/sources/ippcp/src/pcpeccppointopca.c
deleted file mode 100644
index e895dda..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccppointopca.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (EC Point operations)
-//
-// Contents:
-// ippsECCPSetPoint()
-// ippsECCPSetPointAtInfinity()
-// ippsECCPGetPoint()
-//
-// ippsECCPCheckPoint()
-// ippsECCPComparePoint()
-//
-// ippsECCPNegativePoint()
-// ippsECCPAddPoint()
-// ippsECCPMulPointScalar()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsECCPSetPoint
-//
-// Purpose: Converts regular affine coordinates EC point (pX,pY)
-// into internal presentation - montgomery projective.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-// NULL == pX
-// NULL == pY
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pX->idCtx
-// illegal pY->idCtx
-// illegal pPoint->idCtx
-//
-// ippStsOutOfECErr point out-of EC
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pX pointer to the regular affine coordinate X
-// pY pointer to the regular affine coordinate Y
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-// Note:
-// if B==0 and (x,y)=(0,y) then point at Infinity will be set up
-// if B!=0 and (x,y)=(0,0) then point at Infinity will be set up
-// else point with requested coordinates (x,y) wil be set up
-// There are no check validation inside!
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX,
- const IppsBigNumState* pY,
- IppsECCPPointState* pPoint,
- IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test pX and pY */
- IPP_BAD_PTR2_RET(pX,pY);
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
-
- {
- IppStatus sts;
-
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
- IppsGFpElement elmX, elmY;
-
- cpGFpElementConstruct(&elmX, cpGFpGetPool(1, pGFE), elemLen);
- cpGFpElementConstruct(&elmY, cpGFpGetPool(1, pGFE), elemLen);
- do {
- BNU_CHUNK_T* pData = BN_NUMBER(pX);
- int ns = BN_SIZE(pX);
- sts = ippsGFpSetElement((Ipp32u*)pData, BITS2WORD32_SIZE(BITSIZE_BNU(pData, ns)), &elmX, pGF);
- if(ippStsNoErr!=sts) break;
- pData = BN_NUMBER(pY);
- ns = BN_SIZE(pY);
- sts = ippsGFpSetElement((Ipp32u*)pData, BITS2WORD32_SIZE(BITSIZE_BNU(pData, ns)), &elmY, pGF);
- if(ippStsNoErr!=sts) break;
- sts = ippsGFpECSetPoint(&elmX, &elmY, pPoint, pEC);
- } while(0);
-
- cpGFpReleasePool(2, pGFE);
- return sts;
- }
-}
-
-
-/*F*
-// Name: ippsECCPSetPointAtInfinity
-//
-// Purpose: Set point at Infinity
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPoint->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pEC))
-{
- return ippsGFpECSetPointAtInfinity(pPoint, pEC);
-}
-
-
-/*F*
-// Name: ippsECCPGetPoint
-//
-// Purpose: Converts internal presentation EC point - montgomery projective
-// into regular affine coordinates EC point (pX,pY)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPoint->idCtx
-// NULL != pX, illegal pX->idCtx
-// NULL != pY, illegal pY->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pX pointer to the regular affine coordinate X
-// pY pointer to the regular affine coordinate Y
-// pLength pointer to the length of coordinates
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, IppsBigNumState* pY,
- const IppsECCPPointState* pPoint,
- IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test pX and pY */
- if(pX) {
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
- }
- if(pY) {
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
- }
-
- {
- IppStatus sts;
-
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_decode decode = GFP_METHOD(pGFE)->decode; /* gf decode method */
-
- IppsGFpElement elmX, elmY;
-
- cpGFpElementConstruct(&elmX, cpGFpGetPool(1, pGFE), elemLen);
- cpGFpElementConstruct(&elmY, cpGFpGetPool(1, pGFE), elemLen);
- do {
- sts = ippsGFpECGetPoint(pPoint, pX? &elmX:NULL, pY? &elmY:NULL, pEC);
- if(ippStsNoErr!=sts) break;
-
- if(pX) {
- decode(elmX.pData, elmX.pData, pGFE);
- sts = ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)elmX.pData, pX);
- if(ippStsNoErr!=sts) break;
- }
- if(pY) {
- decode(elmY.pData, elmY.pData, pGFE);
- sts = ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)elmY.pData, pY);
- if(ippStsNoErr!=sts) break;
- }
- } while(0);
-
- cpGFpReleasePool(2, pGFE);
- return sts;
- }
-}
-
-
-/*F*
-// Name: ippsECCPCheckPoint
-//
-// Purpose: Check EC point:
-// - is point lie on EC
-// - is point at infinity
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pResult
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-// pResult pointer to the result:
-// ippECValid
-// ippECPointIsNotValid
-// ippECPointIsAtInfinite
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP,
- IppECResult* pResult,
- IppsECCPState* pEC))
-{
- return ippsGFpECTstPoint(pP, pResult, pEC);
-}
-
-
-/*F*
-// Name: ippsECCPComparePoint
-//
-// Purpose: Compare two EC points
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pQ
-// NULL == pResult
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pQ->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the EC Point context
-// pQ pointer to the EC Point context
-// pECC pointer to the ECCP context
-// pResult pointer to the result:
-// ippECPointIsEqual
-// ippECPointIsNotEqual
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- IppECResult* pResult,
- IppsECCPState* pEC))
-{
- return ippsGFpECCmpPoint(pP, pQ, pResult, pEC);
-}
-
-
-/*F*
-// Name: ippsECCPNegativePoint
-//
-// Purpose: Perforn EC point operation: R = -P
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPNegativePoint, (const IppsECCPPointState* pP,
- IppsECCPPointState* pR,
- IppsECCPState* pEC))
-{
- return ippsGFpECNegPoint(pP, pR, pEC);
-}
-
-
-/*F*
-// Name: ippsECCPAddPoint
-//
-// Purpose: Perforn EC point operation: R = P+Q
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pQ
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pQ->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pQ pointer to the source EC Point context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- IppsECCPPointState* pR,
- IppsECCPState* pEC))
-{
- return ippsGFpECAddPoint(pP, pQ, pR, pEC);
-}
-
-
-/*F*
-// Name: ippsECCPMulPointScalar
-//
-// Purpose: Perforn EC point operation: R = k*P
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pK
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pK->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pK pointer to the source BigNum multiplier context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP,
- const IppsBigNumState* pK,
- IppsECCPPointState* pR,
- IppsECCPState* pEC))
-{
- /* use aligned EC context */
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- return ippsGFpECMulPoint(pP, pK, pR, pEC, (Ipp8u*)ECP_SBUFFER(pEC));
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c b/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c
deleted file mode 100644
index 72d11c0..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (Sign, DSA version)
-//
-// Contents:
-// ippsECCPSignDSA()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsECCPSignDSA
-//
-// Purpose: Signing of message representative.
-// (DSA version).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pMsgDigest
-// NULL == pPrivate
-// NULL == pSignX
-// NULL == pSignY
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pMsgDigest->idCtx
-// illegal pPrivate->idCtx
-// illegal pSignX->idCtx
-// illegal pSignY->idCtx
-//
-// ippStsMessageErr MsgDigest >= order
-//
-// ippStsRangeErr not enough room for:
-// signX
-// signY
-//
-// ippStsEphemeralKeyErr (0==signX) || (0==signY)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsgDigest pointer to the message representative to be signed
-// pPrivate pointer to the regular private key
-// pSignX,pSignY pointer to the signature
-// pECC pointer to the ECCP context
-//
-// Note:
-// - ephemeral key pair extracted from pECC and
-// must be generated and before ippsECCPDSASign() usage
-// - ephemeral key pair destroy before exit
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest,
- const IppsBigNumState* pPrivate,
- IppsBigNumState* pSignX, IppsBigNumState* pSignY,
- IppsECCPState* pEC))
-{
- /* use aligned EC context */
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test private key*/
- IPP_BAD_PTR1_RET(pPrivate);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsgDigest);
- pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pMsgDigest), ippStsMessageErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignX,pSignY);
- pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, BN_ALIGNMENT) );
- pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pSignX)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
- IPP_BADARG_RET((BN_ROOM(pSignY)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- {
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsgDigest);
- int msgLen = BN_SIZE(pMsgDigest);
- IPP_BADARG_RET(0<=cpCmp_BNU(pMsgData, msgLen, pOrder, orderLen), ippStsMessageErr);
-
- /* signY = ephPrivate^-1 mod Order*/
- {
- __ALIGN8 IppsBigNumState R;
- BNU_CHUNK_T* buffer = ECP_SBUFFER(pEC);
- /* BN(order) */
- BN_Make(buffer, buffer+orderLen+1, orderLen, &R);
- BN_Set(pOrder, orderLen, &R);
-
- BN_Set(ECP_PRIVAT_E(pEC), orderLen, pSignX);
- ippsModInv_BN(pSignX, &R, pSignY);
- }
-
- {
- IppStatus sts = ippStsEphemeralKeyErr;
-
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- int elmLen = GFP_FELEN(pGFE);
- int pelmLen = GFP_PELEN(pGFE);
-
- BNU_CHUNK_T* pC = cpGFpGetPool(3, pGFE);
- BNU_CHUNK_T* pF = pC + pelmLen;
- BNU_CHUNK_T* pS = pF + pelmLen;
-
- /* ephemeral public */
- IppsGFpECPoint ephPublic;
- cpEcGFpInitPoint(&ephPublic, ECP_PUBLIC_E(pEC), ECP_FINITE_POINT|ECP_AFFINE_POINT, pEC);
-
- /* ephPublic.x */
- gfec_GetPoint(pC, NULL, &ephPublic, pEC);
- GFP_METHOD(pGFE)->decode(pC, pC, pGFE);
-
- /* signX = int(ephPublic.x) (mod order) */
- elmLen = cpMod_BNU(pC, elmLen, pOrder, orderLen);
- cpGFpElementPadd(pC+elmLen, orderLen-elmLen, 0);
- if(!GFP_IS_ZERO(pC, orderLen)) {
-
- /*
- // signY = (1/ephPrivate)*(pMsgDigest + private*signX) (mod order)
- */
- /* S = mont(private) * mont(signX) */
- cpMontEnc_BNU_EX(pF, pC, orderLen, pMontR);
- cpMontEnc_BNU_EX(pS, BN_NUMBER(pPrivate), BN_SIZE(pPrivate), pMontR);
- cpMontMul_BNU(pS, pS, pF, pMontR);
- /* S = (S+ mont(msg) mod order */
- cpGFpElementCopyPadd(pF, orderLen, pMsgData, msgLen);
- cpMontEnc_BNU_EX(pF, pF, orderLen, pMontR);
- cpModAdd_BNU(pS, pS, pF, pOrder, orderLen, pF);
-
- /* S = S*(ephPrivate^-1) */
- cpGFpElementCopyPadd(pF, orderLen, BN_NUMBER(pSignY), BN_SIZE(pSignY));
- cpMontMul_BNU(pS, pS, pF, pMontR);
-
- if(!GFP_IS_ZERO(pS, orderLen)) {
- BNU_CHUNK_T* pSignXdata = BN_NUMBER(pSignX);
- BNU_CHUNK_T* pSignYdata = BN_NUMBER(pSignY);
-
- /* signX */
- elmLen = orderLen;
- FIX_BNU(pC, elmLen);
- BN_SIGN(pSignX) = ippBigNumPOS;
- BN_SIZE(pSignX) = elmLen;
- cpGFpElementCopy(pSignXdata, pC, elmLen);
-
- /* signY */
- elmLen = orderLen;
- FIX_BNU(pS, elmLen);
- BN_SIGN(pSignY) = ippBigNumPOS;
- BN_SIZE(pSignY) = elmLen;
- cpGFpElementCopy(pSignYdata, pS, elmLen);
-
- sts = ippStsNoErr;
- }
- }
-
- cpGFpReleasePool(3, pGFE);
- return sts;
- }
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpeccpsm2dpca.c b/ext/ipp/sources/ippcp/src/pcpeccpsm2dpca.c
deleted file mode 100644
index 7574939..0000000
--- a/ext/ipp/sources/ippcp/src/pcpeccpsm2dpca.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over Prime Finite Field (setup/retrieve domain parameters)
-//
-// Contents:
-// ippsECCPSetStdSM2()
-*/
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*
-// Set ECSM2 parameters
-*/
-IPPFUN(IppStatus, ippsECCPSetStdSM2, (IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- /* set domain parameters */
- return ECCPSetDP(ippsGFpMethod_p256sm2(),
- BITS_BNU_CHUNK(256), tpmSM2_p256_p,
- BITS_BNU_CHUNK(256), tpmSM2_p256_a,
- BITS_BNU_CHUNK(256), tpmSM2_p256_b,
- BITS_BNU_CHUNK(256), tpmSM2_p256_gx,
- BITS_BNU_CHUNK(256), tpmSM2_p256_gy,
- BITS_BNU_CHUNK(256), tpmSM2_p256_r,
- tpmSM2_p256_h,
- pEC);
-}
-
-IPPFUN(IppStatus, ippsECCPBindGxyTblStdSM2,(IppsECCPState* pEC))
-{
- /* test pEC */
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- ECP_PREMULBP(pEC) = gfpec_precom_sm2_fun();
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpecprime.h b/ext/ipp/sources/ippcp/src/pcpecprime.h
deleted file mode 100644
index 7dd6c83..0000000
--- a/ext/ipp/sources/ippcp/src/pcpecprime.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Fixed EC primes
-//
-//
-*/
-
-#if !defined(_PCP_ECPRIME_H)
-#define _PCP_ECPRIME_H
-
-#include "owndefs.h"
-#include "pcpbnuimpl.h"
-
-
-/*
-// Recommended (NIST's) underlying EC Primes
-*/
-extern const BNU_CHUNK_T secp112r1_p[]; // (2^128 -3)/76439
-extern const BNU_CHUNK_T secp112r2_p[]; // (2^128 -3)/76439
-extern const BNU_CHUNK_T secp128r1_p[]; // 2^128 -2^97 -1
-extern const BNU_CHUNK_T secp128r2_p[]; // 2^128 -2^97 -1
-extern const BNU_CHUNK_T secp160r1_p[]; // 2^160 -2^31 -1
-extern const BNU_CHUNK_T secp160r2_p[]; // 2^160 -2^32 -2^14 -2^12 -2^9 -2^8 -2^7 -2^2 -1
-extern const BNU_CHUNK_T secp192r1_p[]; // 2^192 -2^64 -1
-extern const BNU_CHUNK_T secp224r1_p[]; // 2^224 -2^96 +1
-extern const BNU_CHUNK_T secp256r1_p[]; // 2^256 -2^224 +2^192 +2^96 -1
-extern const BNU_CHUNK_T secp384r1_p[]; // 2^384 -2^128 -2^96 +2^32 -1
-extern const BNU_CHUNK_T secp521r1_p[]; // 2^521 -1
-
-extern const BNU_CHUNK_T tpmBN_p256p_p[]; // TPM BN_P256
-
-/*
-// Recommended (SM2) underlying EC Prime
-*/
-extern const BNU_CHUNK_T tpmSM2_p256_p[]; // TPM SM2_P256
-
-#endif /* _PCP_ECPRIME_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpgfp.c b/ext/ipp/sources/ippcp/src/pcpgfp.c
deleted file mode 100644
index 693efe8..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfp.c
+++ /dev/null
@@ -1,1165 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// Operations over GF(p).
-//
-// Context:
-// ippsGFpGetSize()
-// ippsGFpInitArbitrary()
-// ippsGFpInitFixed()
-// ippsGFpInit()
-//
-// ippsGFpElementGetSize()
-// ippsGFpElementInit()
-//
-// ippsGFpSetElement()
-// ippsGFpSetElementRegular()
-// ippsGFpSetElementOctString()
-// ippsGFpSetElementRandom()
-// ippsGFpSetElementHash()
-// ippsGFpSetElementHash_rmf
-// ippsGFpCpyElement()
-// ippsGFpGetElement()
-// ippsGFpGetElementOctString()
-//
-// ippsGFpCmpElement()
-// ippsGFpIsZeroElement()
-// ippsGFpIsUnityElement()
-//
-// ippsGFpSetPolyTerm()
-// ippsGFpGetPolyTerm()
-//
-// ippsGFpConj()
-// ippsGFpNeg()
-// ippsGFpInv()
-// ippsGFpSqrt()
-// ippsGFpAdd()
-// ippsGFpSub()
-// ippsGFpMul()
-// ippsGFpSqr()
-// ippsGFpExp()
-// ippsGFpMultiExp()
-//
-// ippsGFpAdd_GFpE()
-// ippsGFpSub_GFpE()
-// ippsGFpMul_GFpE()
-//
-//
-*/
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpstuff.h"
-#include "pcpgfpxstuff.h"
-#include "pcphash.h"
-#include "pcphash_rmf.h"
-#include "pcptool.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-
-/*
-// size of GFp engine context (Montgomery)
-*/
-int cpGFpGetSize(int feBitSize, int peBitSize, int numpe)
-{
- int ctxSize = 0;
- int elemLen = BITS_BNU_CHUNK(feBitSize);
- int pelmLen = BITS_BNU_CHUNK(peBitSize);
-
- /* size of GFp engine */
- ctxSize = sizeof(gsModEngine)
- + elemLen*sizeof(BNU_CHUNK_T) /* modulus */
- + elemLen*sizeof(BNU_CHUNK_T) /* mont_R */
- + elemLen*sizeof(BNU_CHUNK_T) /* mont_R^2 */
- + elemLen*sizeof(BNU_CHUNK_T) /* half of modulus */
- + elemLen*sizeof(BNU_CHUNK_T) /* quadratic non-residue */
- + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* pool */
-
- ctxSize += sizeof(IppsGFpState); /* size of IppsGFPState */
- return ctxSize;
-}
-
-IPPFUN(IppStatus, ippsGFpGetSize,(int feBitSize, int* pSize))
-{
- IPP_BAD_PTR1_RET(pSize);
- IPP_BADARG_RET((feBitSize < 2) || (feBitSize > GFP_MAX_BITSIZE), ippStsSizeErr);
-
- *pSize = cpGFpGetSize(feBitSize, feBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE)
- + GFP_ALIGNMENT;
- return ippStsNoErr;
-}
-
-
-/*
-// init GFp engine context (Montgomery)
-*/
-static void cpGFEInit(gsModEngine* pGFE, int modulusBitSize, int peBitSize, int numpe)
-{
- int modLen = BITS_BNU_CHUNK(modulusBitSize);
- int pelmLen = BITS_BNU_CHUNK(peBitSize);
-
- Ipp8u* ptr = (Ipp8u*)pGFE;
-
- /* clear whole context */
- PaddBlock(0, ptr, sizeof(gsModEngine));
- ptr += sizeof(gsModEngine);
-
- GFP_PARENT(pGFE) = NULL;
- GFP_EXTDEGREE(pGFE) = 1;
- GFP_FEBITLEN(pGFE) = modulusBitSize;
- GFP_FELEN(pGFE) = modLen;
- GFP_FELEN32(pGFE) = BITS2WORD32_SIZE(modulusBitSize);
- GFP_PELEN(pGFE) = pelmLen;
- //GFP_METHOD(pGFE) = method;
- GFP_MODULUS(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
- GFP_MNT_R(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
- GFP_MNT_RR(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
- GFP_HMODULUS(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
- GFP_QNR(pGFE) = (BNU_CHUNK_T*)(ptr); ptr += modLen*sizeof(BNU_CHUNK_T);
- GFP_POOL(pGFE) = (BNU_CHUNK_T*)(ptr);/* ptr += modLen*sizeof(BNU_CHUNK_T);*/
- GFP_MAXPOOL(pGFE) = numpe;
- GFP_USEDPOOL(pGFE) = 0;
-
- cpGFpElementPadd(GFP_MODULUS(pGFE), modLen, 0);
- cpGFpElementPadd(GFP_MNT_R(pGFE), modLen, 0);
- cpGFpElementPadd(GFP_MNT_RR(pGFE), modLen, 0);
- cpGFpElementPadd(GFP_HMODULUS(pGFE), modLen, 0);
- cpGFpElementPadd(GFP_QNR(pGFE), modLen, 0);
-}
-
-static void cpGFEqnr(gsModEngine* pGFE)
-{
- BNU_CHUNK_T* pQnr = GFP_QNR(pGFE);
-
- int elemLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* e = cpGFpGetPool(3, pGFE);
- BNU_CHUNK_T* t = e+elemLen;
- BNU_CHUNK_T* p1 = t+elemLen;
- //gres: temporary excluded: assert(NULL!=e);
-
- cpGFpElementCopyPadd(p1, elemLen, GFP_MNT_R(pGFE), elemLen);
-
- /* (modulus-1)/2 */
- cpLSR_BNU(e, GFP_MODULUS(pGFE), elemLen, 1);
-
- /* find a non-square g, where g^{(modulus-1)/2} = -1 */
- cpGFpElementCopy(pQnr, p1, elemLen);
- do {
- cpGFpAdd(pQnr, pQnr, p1, pGFE);
- cpGFpExp(t, pQnr, e, elemLen, pGFE);
- cpGFpNeg(t, t, pGFE);
- } while( !GFP_EQ(p1, t, elemLen) );
-
- cpGFpReleasePool(3, pGFE);
-}
-
-static void cpGFESet(gsModEngine* pGFE, const BNU_CHUNK_T* pPrime, int primeBitSize, const gsModMethod* method)
-{
- int primeLen = BITS_BNU_CHUNK(primeBitSize);
-
- /* arithmetic methods */
- GFP_METHOD(pGFE) = method;
-
- /* store modulus */
- COPY_BNU(GFP_MODULUS(pGFE), pPrime, primeLen);
-
- /* montgomery factor */
- GFP_MNT_FACTOR(pGFE) = gsMontFactor(GFP_MODULUS(pGFE)[0]);
-
- /* montgomery identity (R) */
- ZEXPAND_BNU(GFP_MNT_R(pGFE), 0, primeLen);
- GFP_MNT_R(pGFE)[primeLen] = 1;
- cpMod_BNU(GFP_MNT_R(pGFE), primeLen+1, GFP_MODULUS(pGFE), primeLen);
-
- /* montgomery domain converter (RR) */
- ZEXPAND_BNU(GFP_MNT_RR(pGFE), 0, primeLen);
- COPY_BNU(GFP_MNT_RR(pGFE)+primeLen, GFP_MNT_R(pGFE), primeLen);
- cpMod_BNU(GFP_MNT_RR(pGFE), 2*primeLen, GFP_MODULUS(pGFE), primeLen);
-
- /* half of modulus */
- cpLSR_BNU(GFP_HMODULUS(pGFE), GFP_MODULUS(pGFE), primeLen, 1);
-
- /* set qnr value */
- cpGFEqnr(pGFE);
-}
-
-IppStatus cpGFpInitGFp(int primeBitSize, IppsGFpState* pGF)
-{
- IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
- IPP_BAD_PTR1_RET(pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
-
- {
- Ipp8u* ptr = (Ipp8u*)pGF;
-
- GFP_ID(pGF) = idCtxGFP;
- GFP_PMA(pGF) = (gsModEngine*)(ptr+sizeof(IppsGFpState));
- cpGFEInit(GFP_PMA(pGF), primeBitSize, primeBitSize+BITSIZE(BNU_CHUNK_T), GFP_POOL_SIZE);
-
- return ippStsNoErr;
- }
-}
-
-IppStatus cpGFpSetGFp(const BNU_CHUNK_T* pPrime, int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF)
-{
- cpGFESet(GFP_PMA(pGF), pPrime, primeBitSize, method->arith);
- return ippStsNoErr;
-}
-
-/*F*
-// Name: ippsGFpInitFixed
-//
-// Purpose: initializes prime finite field GF(p)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == method
-// NULL == pGF
-//
-// ippStsBadArgErr method != ippsGFpMethod_pXXX() any fixed prime method
-// primeBitSize != sizeof modulus defined by fixed method
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// primeBitSize length of prime in bits
-// method pointer to the basic arithmetic metods
-// pGF pointer to Finite Field context is being initialized
-*F*/
-IPPFUN(IppStatus, ippsGFpInitFixed,(int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF))
-{
- IPP_BAD_PTR2_RET(method, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
-
- /* test method is prime based */
- IPP_BADARG_RET(cpID_Prime!=(method->modulusID & cpID_Prime), ippStsBadArgErr);
- /* test if method is not prime based arbitrary */
- IPP_BADARG_RET(!method->modulus, ippStsBadArgErr);
- /* size of the underlying prime must be equal to primeBitSize parameter*/
- IPP_BADARG_RET(method->modulusBitDeg!=primeBitSize, ippStsBadArgErr);
-
- {
- /* init GF */
- IppStatus sts = cpGFpInitGFp(primeBitSize, pGF);
-
- /* set up GF engine */
- if(ippStsNoErr==sts) {
- gsModEngine* pGFE = GFP_PMA(pGF);
- cpGFESet(pGFE, method->modulus, primeBitSize, method->arith);
- }
-
- return sts;
- }
-}
-
-/*F*
-// Name: ippsGFpInitArbitrary
-//
-// Purpose: initializes prime finite field GF(p)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPrime
-// NULL == pGF
-//
-// ippStsSizeErr !(IPP_MIN_GF_BITSIZE <= primeBitSize <=IPP_MAX_GF_BITSIZE)
-//
-// ippStsContextMatchErr incorrect pPrime context ID
-//
-// ippStsBadArgErr prime <0
-// bitsize(prime) != primeBitSize
-// prime <IPP_MIN_GF_CHAR
-// prime is even
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pPrimeBN pointer to the prime context
-// primeBitSize length of prime in bits
-// pGF pointer to Finite Field context is being initialized
-*F*/
-IPPFUN(IppStatus, ippsGFpInitArbitrary,(const IppsBigNumState* pPrimeBN, int primeBitSize, IppsGFpState* pGF))
-{
- IPP_BAD_PTR1_RET(pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
-
- IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pPrimeBN);
- pPrimeBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrimeBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrimeBN), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_SIGN(pPrimeBN)!= IppsBigNumPOS, ippStsBadArgErr); /* prime is negative */
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrimeBN),BN_SIZE(pPrimeBN)) != primeBitSize, ippStsBadArgErr); /* primeBitSize == bitsize(prime) */
- IPP_BADARG_RET((BN_SIZE(pPrimeBN)==1) && (BN_NUMBER(pPrimeBN)[0]<IPP_MIN_GF_CHAR), ippStsBadArgErr); /* prime < 3 */
- IPP_BADARG_RET(0==(BN_NUMBER(pPrimeBN)[0] & 1), ippStsBadArgErr); /* prime is even */
-
- {
- /* init GF */
- IppStatus sts = cpGFpInitGFp(primeBitSize, pGF);
-
- /* set up GF engine */
- if(ippStsNoErr==sts) {
- gsModEngine* pGFE = GFP_PMA(pGF);
- cpGFESet(pGFE, BN_NUMBER(pPrimeBN), primeBitSize, ippsGFpMethod_pArb()->arith);
- }
-
- return sts;
- }
-}
-
-/*F*
-// Name: ippsGFpInit
-//
-// Purpose: initializes prime finite field GF(p)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == method
-// NULL == pGF
-//
-// ippStsSizeErr !(IPP_MIN_GF_BITSIZE <= primeBitSize <=IPP_MAX_GF_BITSIZE
-//
-// ippStsContextMatchErr invalid pPrime->idCtx
-//
-// ippStsBadArgErr method != ippsGFpMethod_pXXX() or != ippsGFpMethod_pArb()
-// prime != method->modulus
-// prime <0
-// bitsize(prime) != primeBitSize
-// prime <IPP_MIN_GF_CHAR
-// prime is even
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pPrimeBN pointer to the data representation Finite Field element
-// primeBitSize length of Finite Field data representation array
-// method pointer to Finite Field Element context
-// pGF pointer to Finite Field context is being initialized
-*F*/
-IPPFUN(IppStatus, ippsGFpInit,(const IppsBigNumState* pPrimeBN, int primeBitSize, const IppsGFpMethod* method, IppsGFpState* pGF))
-{
- IPP_BADARG_RET(!pPrimeBN && !method, ippStsNullPtrErr);
-
- IPP_BADARG_RET((primeBitSize< IPP_MIN_GF_BITSIZE) || (primeBitSize> IPP_MAX_GF_BITSIZE), ippStsSizeErr);
-
- /* use ippsGFpInitFixed() if NULL==pPrimeBN */
- if(!pPrimeBN)
- return ippsGFpInitFixed(primeBitSize, method, pGF);
-
- /* use ippsGFpInitArbitrary() if NULL==method */
- if(!method)
- return ippsGFpInitArbitrary(pPrimeBN, primeBitSize, pGF);
-
- /* test parameters if both pPrimeBN and method are defined */
- else {
- IppStatus sts;
-
- /* test input prime */
- pPrimeBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrimeBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrimeBN), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_SIGN(pPrimeBN)!= IppsBigNumPOS, ippStsBadArgErr); /* prime is negative */
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrimeBN),BN_SIZE(pPrimeBN)) != primeBitSize, ippStsBadArgErr); /* primeBitSize == bitsize(prime) */
- IPP_BADARG_RET((BN_SIZE(pPrimeBN)==1) && (BN_NUMBER(pPrimeBN)[0]<IPP_MIN_GF_CHAR), ippStsBadArgErr); /* prime < 3 */
- IPP_BADARG_RET(0==(BN_NUMBER(pPrimeBN)[0] & 1), ippStsBadArgErr); /* prime is even */
-
- /* test if method is prime based */
- IPP_BADARG_RET(cpID_Prime!=(method->modulusID & cpID_Prime), ippStsBadArgErr);
-
- /* test if size of the prime is matched to method's prime */
- IPP_BADARG_RET(method->modulusBitDeg && (primeBitSize!=method->modulusBitDeg), ippStsBadArgErr);
-
- /* if method assumes fixed prime value */
- if(method->modulus) {
- int primeLen = BITS_BNU_CHUNK(primeBitSize);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pPrimeBN), primeLen, method->modulus, primeLen), ippStsBadArgErr);
- }
-
- /* init GF */
- sts = cpGFpInitGFp(primeBitSize, pGF);
-
- /* set up GF and find quadratic nonresidue */
- if(ippStsNoErr==sts) {
- gsModEngine* pGFE = GFP_PMA(pGF);
- cpGFESet(pGFE, BN_NUMBER(pPrimeBN), primeBitSize, method->arith);
- }
-
- return sts;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGF, int* pBufferSize))
-{
- IPP_BAD_PTR2_RET(pGF, pBufferSize);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- IPP_BADARG_RET( 0>=nExponents ||nExponents>IPP_MAX_EXPONENT_NUM, ippStsBadArgErr);
- IPP_BADARG_RET( 0>=ExpBitSize, ippStsBadArgErr);
-
- {
- int elmDataSize = GFP_FELEN(GFP_PMA(pGF))*sizeof(BNU_CHUNK_T);
-
- /* get window_size */
- int w = (nExponents==1)? cpGFpGetOptimalWinSize(ExpBitSize) : /* use optimal window size, if single-scalar operation */
- nExponents; /* or pseudo-oprimal if multi-scalar operation */
-
- /* number of table entries */
- int nPrecomputed = 1<<w;
-
- *pBufferSize = elmDataSize*nPrecomputed + (CACHE_LINE_SIZE-1);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpElementGetSize,(const IppsGFpState* pGF, int* pElementSize))
-{
- IPP_BAD_PTR2_RET(pElementSize, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- *pElementSize = sizeof(IppsGFpElement)
- +GFP_FELEN(GFP_PMA(pGF))*sizeof(BNU_CHUNK_T);
- return ippStsNoErr;
-}
-
-
-IPPFUN(IppStatus, ippsGFpElementInit,(const Ipp32u* pA, int nsA, IppsGFpElement* pR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR2_RET(pR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- IPP_BADARG_RET(0>nsA, ippStsSizeErr);
-
- {
- int elemLen = GFP_FELEN(GFP_PMA(pGF));
-
- Ipp8u* ptr = (Ipp8u*)pR;
- ptr += sizeof(IppsGFpElement);
- cpGFpElementConstruct(pR, (BNU_CHUNK_T*)ptr, elemLen);
- return ippsGFpSetElement(pA, nsA, pR, pGF);
- }
-}
-
-/*F*
-// Name: ippsGFpSetElement
-//
-// Purpose: Set GF Element
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGF
-// NULL == pElm
-// NULL == pDataA && nsA>0
-//
-// ippStsContextMatchErr invalid pGF->idCtx
-// invalid pElm->idCtx
-//
-// ippStsSizeErr pDataA && !(0<=nsA && nsA<GFP_FELEN32())
-//
-// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
-// BNU representation of pDataA[i]..pDataA[i+GFP_FELEN32()-1] >= modulus
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pDataA pointer to the data representation Finite Field element
-// nsA length of Finite Field data representation array
-// pElm pointer to Finite Field Element context
-// pGF pointer to Finite Field context
-*F*/
-IPPFUN(IppStatus, ippsGFpSetElement,(const Ipp32u* pDataA, int nsA, IppsGFpElement* pElm, IppsGFpState* pGF))
-{
- IPP_BAD_PTR2_RET(pElm, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr );
-
- IPP_BADARG_RET( !pDataA && (0<nsA), ippStsNullPtrErr);
- IPP_BADARG_RET( pDataA && !(0<=nsA && nsA<=GFP_FELEN32(GFP_PMA(pGF))), ippStsSizeErr );
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(GFP_PMA(pGF)), ippStsOutOfRangeErr );
-
- {
- IppStatus sts = ippStsNoErr;
-
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(NULL!=pTmp);
-
- ZEXPAND_BNU(pTmp, 0, elemLen);
- if(pDataA && nsA)
- cpGFpxCopyToChunk(pTmp, pDataA, nsA, pGFE);
-
- if(!cpGFpxSet(GFPE_DATA(pElm), pTmp, elemLen, pGFE))
- sts = ippStsOutOfRangeErr;
-
- cpGFpReleasePool(1, pGFE);
- return sts;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpSetElementRegular,(const IppsBigNumState* pBN, IppsGFpElement* pElm, IppsGFpState* pGF))
-{
- IPP_BAD_PTR1_RET(pBN);
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET( !BN_VALID_ID(pBN), ippStsContextMatchErr );
- IPP_BADARG_RET( !BN_POSITIVE(pBN), ippStsOutOfRangeErr);
-
- return ippsGFpSetElement((Ipp32u*)BN_NUMBER(pBN), BITS2WORD32_SIZE( BITSIZE_BNU(BN_NUMBER((pBN)),BN_SIZE((pBN)))), pElm, pGF);
-}
-
-/*F*
-// Name: ippsGFpSetElementOctString
-//
-// Purpose: Set GF Element
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGF
-// NULL == pElm
-// NULL == pStr && strSize>0
-//
-// ippStsContextMatchErr invalid pGF->idCtx
-// invalid pElm->idCtx
-//
-// ippStsSizeErr pDataA && !(0<=nsA && nsA<GFP_FELEN32())
-//
-// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
-// BNU representation of pStr[] >= modulus
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pDataA pointer to the data representation Finite Field element
-// nsA length of Finite Field data representation array
-// pElm pointer to Finite Field Element context
-// pGF pointer to Finite Field context
-*F*/
-IPPFUN(IppStatus, ippsGFpSetElementOctString,(const Ipp8u* pStr, int strSize, IppsGFpElement* pElm, IppsGFpState* pGF))
-{
- IPP_BAD_PTR2_RET(pElm, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr );
-
- IPP_BADARG_RET( (!pStr && 0<strSize), ippStsNullPtrErr);
- IPP_BADARG_RET(!(0<strSize && strSize<=(int)(GFP_FELEN32(GFP_PMA(pGF))*sizeof(Ipp32u))), ippStsSizeErr );
-
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(GFP_PMA(pGF)), ippStsOutOfRangeErr);
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFE);
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGFE),GFP_FELEN(pBasicGFE)));
-
- BNU_CHUNK_T* pDataElm = GFPE_DATA(pElm);
-
- int deg, error;
- /* set element to zero */
- cpGFpElementPadd(pDataElm, GFP_FELEN(pGFE), 0);
-
- /* convert oct string to element (from low to high) */
- for(deg=0, error=0; deg<basicDeg && !error; deg++) {
- int size = IPP_MIN(strSize, basicSize);
- error = NULL == cpGFpSetOctString(pDataElm, pStr, size, pBasicGFE);
-
- pDataElm += basicElemLen;
- strSize -= size;
- pStr += size;
- }
-
- return error? ippStsOutOfRangeErr : ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsGFpSetElementRandom
-//
-// Purpose: Set GF Element Random
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGF
-// NULL == pElm
-// NULL == rndFunc
-//
-// ippStsContextMatchErr invalid pGF->idCtx
-// invalid pElm->idCtx
-//
-// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
-//
-// ippStsErr internal error caused by call of rndFunc()
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pDataA pointer to the data representation Finite Field element
-// nsA length of Finite Field data representation array
-// pElm pointer to Finite Field Element context
-// pGF pointer to Finite Field context
-*F*/
-IPPFUN(IppStatus, ippsGFpSetElementRandom,(IppsGFpElement* pElm, IppsGFpState* pGF,
- IppBitSupplier rndFunc, void* pRndParam))
-{
- IPP_BAD_PTR3_RET(pElm, pGF, rndFunc);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- return cpGFpxRand(GFPE_DATA(pElm), pGFE, rndFunc, pRndParam)? ippStsNoErr : ippStsErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpCpyElement, (const IppsGFpElement* pElmA, IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- cpGFpElementCopy(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFP_FELEN(pGFE));
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpGetElement, (const IppsGFpElement* pElm, Ipp32u* pDataA, int nsA, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElm, pDataA, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- IPP_BADARG_RET( !(0<nsA && nsA>=GFP_FELEN32(pGFE)), ippStsSizeErr );
-
- {
- int elemLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(NULL!=pTmp);
-
- cpGFpxGet(pTmp, elemLen, GFPE_DATA(pElm), pGFE);
- cpGFpxCopyFromChunk(pDataA, pTmp, pGFE);
-
- cpGFpReleasePool(1, pGFE);
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpGetElementOctString,(const IppsGFpElement* pElm, Ipp8u* pStr, int strSize, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pStr, pElm, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr );
- IPP_BADARG_RET( 0>=strSize, ippStsSizeErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFE);
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGFE),GFP_FELEN(pBasicGFE)));
-
- BNU_CHUNK_T* pDataElm = GFPE_DATA(pElm);
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- int size = IPP_MIN(strSize, basicSize);
- cpGFpGetOctString(pStr, size, pDataElm, pBasicGFE);
-
- pDataElm += basicElemLen;
- pStr += size;
- strSize -= size;
- }
-
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpCmpElement,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB,
- int* pResult,
- const IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pElmB, pResult, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmB)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- {
- int flag = cpGFpElementCmp(GFPE_DATA(pElmA), GFPE_DATA(pElmB), GFP_FELEN(pGFE));
- if( GFP_IS_BASIC(pGFE) )
- *pResult = (0==flag)? IPP_IS_EQ : (0<flag)? IPP_IS_GT : IPP_IS_LT;
- else
- *pResult = (0==flag)? IPP_IS_EQ : IPP_IS_NE;
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpIsZeroElement,(const IppsGFpElement* pElmA,
- int* pResult,
- const IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pResult, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- {
- int flag = GFP_IS_ZERO(GFPE_DATA(pElmA), GFP_FELEN(pGFE));
- *pResult = (1==flag)? IPP_IS_EQ : IPP_IS_NE;
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpIsUnityElement,(const IppsGFpElement* pElmA,
- int* pResult,
- const IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pResult, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
- int basicElmLen = GFP_FELEN(pBasicGFE);
- BNU_CHUNK_T* pUnity = GFP_MNT_R(pBasicGFE);
-
- int elmLen = GFP_FELEN(pGFE);
- int flag;
-
- FIX_BNU(pUnity, basicElmLen);
- FIX_BNU(GFPE_DATA(pElmA), elmLen);
-
- flag = (basicElmLen==elmLen) && (0 == cpGFpElementCmp(GFPE_DATA(pElmA), pUnity, elmLen));
- *pResult = (1==flag)? IPP_IS_EQ : IPP_IS_NE;
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpConj,(const IppsGFpElement* pElmA,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- IPP_BADARG_RET( 2!=GFP_EXTDEGREE(pGFE), ippStsBadArgErr )
-
- cpGFpxConj(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpNeg,(const IppsGFpElement* pElmA,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- GFP_METHOD(pGFE)->neg(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGFE);
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpInv,(const IppsGFpElement* pElmA,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- IPP_BADARG_RET( GFP_IS_ZERO(GFPE_DATA(pElmA),GFP_FELEN(pGFE)), ippStsDivByZeroErr );
-
- return NULL != cpGFpxInv(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGFE)? ippStsNoErr : ippStsBadArgErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpSqrt,(const IppsGFpElement* pElmA,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr )
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- return cpGFpSqrt(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGFE)? ippStsNoErr : ippStsQuadraticNonResidueErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpAdd,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- GFP_METHOD(pGFE)->add(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB), pGFE);
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpSub,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- GFP_METHOD(pGFE)->sub(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpMul,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmB)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- GFP_METHOD(pGFE)->mul(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB),pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpSqr,(const IppsGFpElement* pElmA,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR3_RET(pElmA, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- GFP_METHOD(pGFE)->sqr(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpAdd_PE,(const IppsGFpElement* pElmA, const IppsGFpElement* pParentElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pParentElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pParentElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- IPP_BADARG_RET( (GFPE_ROOM(pParentElmB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
-
- cpGFpxAdd_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pParentElmB), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpSub_PE,(const IppsGFpElement* pElmA, const IppsGFpElement* pParentElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pParentElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pParentElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- IPP_BADARG_RET( (GFPE_ROOM(pParentElmB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
-
- cpGFpxSub_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pParentElmB), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpMul_PE,(const IppsGFpElement* pElmA, const IppsGFpElement* pParentElmB,
- IppsGFpElement* pElmR, IppsGFpState* pGF))
-{
- IPP_BAD_PTR4_RET(pElmA, pParentElmB, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pParentElmB), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFP_IS_BASIC(pGFE), ippStsBadArgErr )
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- IPP_BADARG_RET( (GFPE_ROOM(pParentElmB)!=GFP_FELEN(GFP_PARENT(pGFE))), ippStsOutOfRangeErr);
-
- cpGFpxMul_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pParentElmB), pGFE);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpExp,(const IppsGFpElement* pElmA, const IppsBigNumState* pE,
- IppsGFpElement* pElmR, IppsGFpState* pGF,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR4_RET(pElmA, pE, pElmR, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
-
- pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
- IPP_BADARG_RET( !BN_VALID_ID(pE), ippStsContextMatchErr );
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
-
- cpGFpxExp(GFPE_DATA(pElmR), GFPE_DATA(pElmA), BN_NUMBER(pE), BN_SIZE(pE), pGFE, pScratchBuffer);
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems,
- IppsGFpElement* pElmR, IppsGFpState* pGF,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR2_RET(ppElmA, ppE);
-
- if(nItems==1)
- return ippsGFpExp(ppElmA[0], ppE[0], pElmR, pGF, pScratchBuffer);
-
- else {
- /* test number of exponents */
- IPP_BADARG_RET(1>nItems || nItems>IPP_MAX_EXPONENT_NUM, ippStsBadArgErr);
-
- IPP_BAD_PTR2_RET(pElmR, pGF);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr );
- {
- int n;
-
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- /* test all ppElmA[] and ppE[] pairs */
- for(n=0; n<nItems; n++) {
- const IppsGFpElement* pElmA = ppElmA[n];
- const IppsBigNumState* pE = ppE[n];
- IPP_BAD_PTR2_RET(pElmA, pE);
-
- IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr );
- pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
- IPP_BADARG_RET( !BN_VALID_ID(pE), ippStsContextMatchErr );
-
- IPP_BADARG_RET( (GFPE_ROOM(pElmA)!=GFP_FELEN(pGFE)) || (GFPE_ROOM(pElmR)!=GFP_FELEN(pGFE)), ippStsOutOfRangeErr);
- }
-
- if(NULL==pScratchBuffer) {
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
-
- BNU_CHUNK_T* pTmpR = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(NULL!=pTmpR);
-
- cpGFpxExp(GFPE_DATA(pElmR), GFPE_DATA(ppElmA[0]), BN_NUMBER(ppE[0]), BN_SIZE(ppE[0]), pGFE, 0);
- for(n=1; n<nItems; n++) {
- cpGFpxExp(pTmpR, GFPE_DATA(ppElmA[n]), BN_NUMBER(ppE[n]), BN_SIZE(ppE[n]), pGFE, 0);
- mulF(GFPE_DATA(pElmR), GFPE_DATA(pElmR), pTmpR, pGFE);
- }
-
- cpGFpReleasePool(1, pGFE);
- }
-
- else {
- const BNU_CHUNK_T* ppAdata[IPP_MAX_EXPONENT_NUM];
- const BNU_CHUNK_T* ppEdata[IPP_MAX_EXPONENT_NUM];
- int nsEdataLen[IPP_MAX_EXPONENT_NUM];
- for(n=0; n<nItems; n++) {
- ppAdata[n] = GFPE_DATA(ppElmA[n]);
- ppEdata[n] = BN_NUMBER(ppE[n]);
- nsEdataLen[n] = BN_SIZE(ppE[n]);
- }
- cpGFpxMultiExp(GFPE_DATA(pElmR), ppAdata, ppEdata, nsEdataLen, nItems, pGFE, pScratchBuffer);
- }
-
- return ippStsNoErr;
- }
- }
-}
-
-/*F*
-// Name: ippsGFpSetElementHash
-//
-// Purpose: Set GF Element Hash of the Message
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGF
-// NULL == pElm
-// NULL == pMsg if msgLen>0
-//
-// ippStsNotSupportedModeErr hashID is not supported
-//
-// ippStsContextMatchErr invalid pGF->idCtx
-// invalid pElm->idCtx
-//
-// ippStsOutOfRangeErr GFPE_ROOM() != GFP_FELEN()
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pMsg pointer to the message is beinh hashed
-// msgLen length of the message above
-// pElm pointer to Finite Field Element context
-// pGF pointer to Finite Field context
-// hashID applied hash algothith ID
-*F*/
-IPPFUN(IppStatus, ippsGFpSetElementHash,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGF, IppHashAlgId hashID))
-{
- /* get algorithm id */
- hashID = cpValidHashAlg(hashID);
- IPP_BADARG_RET(ippHashAlg_Unknown==hashID, ippStsNotSupportedModeErr);
-
- /* test message length and pointer */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- IPP_BAD_PTR2_RET(pElm, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr);
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr);
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- {
- Ipp8u md[MAX_HASH_SIZE];
- BNU_CHUNK_T hashVal[(MAX_HASH_SIZE*8)/BITSIZE(BNU_CHUNK_T)+1]; /* +1 to meet cpMod_BNU() implementtaion specific */
- IppStatus sts = ippsHashMessage(pMsg, msgLen, md, hashID);
-
- if(ippStsNoErr==sts) {
- int elemLen = GFP_FELEN(pGFE);
- int hashLen = cpHashAlgAttr[hashID].hashSize;
- int hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
- hashValLen = cpMod_BNU(hashVal, hashValLen, GFP_MODULUS(pGFE), elemLen);
- cpGFpSet(GFPE_DATA(pElm), hashVal, hashValLen, pGFE);
- }
-
- return sts;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpSetElementHash_rmf,(const Ipp8u* pMsg, int msgLen, IppsGFpElement* pElm, IppsGFpState* pGF, const IppsHashMethod* pMethod))
-{
- /* test method pointer */
- IPP_BAD_PTR1_RET(pMethod);
-
- /* test message length and pointer */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- IPP_BAD_PTR2_RET(pElm, pGF);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr);
- IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr);
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- IPP_BADARG_RET( GFPE_ROOM(pElm)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- {
- Ipp8u md[MAX_HASH_SIZE];
- BNU_CHUNK_T hashVal[(MAX_HASH_SIZE*8)/BITSIZE(BNU_CHUNK_T)+1]; /* +1 to meet cpMod_BNU() implementtaion specific */
- IppStatus sts = ippsHashMessage_rmf(pMsg, msgLen, md, pMethod);
-
- if(ippStsNoErr==sts) {
- int elemLen = GFP_FELEN(pGFE);
- int hashLen = pMethod->hashLen;
- int hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
- hashValLen = cpMod_BNU(hashVal, hashValLen, GFP_MODULUS(pGFE), elemLen);
- cpGFpSet(GFPE_DATA(pElm), hashVal, hashValLen, pGFE);
- }
-
- return sts;
- }
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpec.c b/ext/ipp/sources/ippcp/src/pcpgfpec.c
deleted file mode 100644
index ee810f6..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpec.c
+++ /dev/null
@@ -1,881 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// EC over GF(p^m) definitinons
-//
-// Context:
-// ippsGFpECGetSize()
-// ippsGFpECInit()
-//
-// ippsGFpECInitStd192r1
-// ippsGFpECInitStd224r1
-// ippsGFpECInitStd256r1
-// ippsGFpECInitStd384r1
-// ippsGFpECInitStd521r1
-// ippsGFpECInitStdSM2
-// ippsGFpECInitStdBN256
-//
-// ippsGFpECSet()
-// ippsGFpECSetSubgroup()
-//
-// ippsGFpECBindGxyTblStd192r1
-// ippsGFpECBindGxyTblStd224r1
-// ippsGFpECBindGxyTblStd256r1
-// ippsGFpECBindGxyTblStd384r1
-// ippsGFpECBindGxyTblStd521r1
-// ippsGFpECBindGxyTblStdSM2
-//
-// ippsGFpECGet()
-// ippsGFpECGetSubgroup()
-//
-// ippsGFpECScratchBufferSize()
-// ippsGFpECVerify()
-//
-//
-*/
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpecstuff.h"
-#include "pcpeccp.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-int cpGFpECGetSize(int basicDeg, int basicElmBitSize)
-{
- int ctxSize = 0;
- int elemLen = basicDeg*BITS_BNU_CHUNK(basicElmBitSize);
-
- int maxOrderBits = 1+ basicDeg*basicElmBitSize;
- #if defined(_LEGACY_ECCP_SUPPORT_)
- int maxOrderLen = BITS_BNU_CHUNK(maxOrderBits);
- #endif
-
- int modEngineCtxSize;
- if(ippStsNoErr==gsModEngineGetSize(maxOrderBits, MONT_DEFAULT_POOL_LENGTH, &modEngineCtxSize)) {
-
- ctxSize = sizeof(IppsGFpECState)
- +elemLen*sizeof(BNU_CHUNK_T) /* EC coeff A */
- +elemLen*sizeof(BNU_CHUNK_T) /* EC coeff B */
- +elemLen*sizeof(BNU_CHUNK_T) /* generator G.x */
- +elemLen*sizeof(BNU_CHUNK_T) /* generator G.y */
- +elemLen*sizeof(BNU_CHUNK_T) /* generator G.z */
- +modEngineCtxSize /* mont engine (R) */
- +elemLen*sizeof(BNU_CHUNK_T) /* cofactor */
- #if defined(_LEGACY_ECCP_SUPPORT_)
- +2*elemLen*3*sizeof(BNU_CHUNK_T) /* regular and ephemeral public keys */
- +2*maxOrderLen*sizeof(BNU_CHUNK_T) /* regular and ephemeral private keys */
- #endif
- +elemLen*sizeof(BNU_CHUNK_T)*3*EC_POOL_SIZE;
- }
- return ctxSize;
-}
-
-IPPFUN(IppStatus, ippsGFpECGetSize,(const IppsGFpState* pGF, int* pCtxSize))
-{
- IPP_BAD_PTR2_RET(pGF, pCtxSize);
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
- *pCtxSize = cpGFpECGetSize(cpGFpBasicDegreeExtension(pGFE), GFP_FEBITLEN(cpGFpBasic(pGFE)))
- + ECGFP_ALIGNMENT;
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECInit,(const IppsGFpState* pGF,
- const IppsGFpElement* pA, const IppsGFpElement* pB,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- {
- Ipp8u* ptr = (Ipp8u*)pEC;
-
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- int maxOrderBits = 1+ cpGFpBasicDegreeExtension(pGFE) * GFP_FEBITLEN(cpGFpBasic(pGFE));
- #if defined(_LEGACY_ECCP_SUPPORT_)
- int maxOrdLen = BITS_BNU_CHUNK(maxOrderBits);
- #endif
-
- int modEngineCtxSize;
- gsModEngineGetSize(maxOrderBits, MONT_DEFAULT_POOL_LENGTH, &modEngineCtxSize);
-
- ECP_ID(pEC) = idCtxGFPEC;
- ECP_GFP(pEC) = (IppsGFpState*)(IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT));
- ECP_POINTLEN(pEC) = elemLen*3;
- ECP_ORDBITSIZE(pEC) = maxOrderBits;
- ECP_SPECIFIC(pEC) = ECP_ARB;
-
- ptr += sizeof(IppsGFpECState);
- ECP_A(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
- ECP_B(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
- ECP_G(pEC) = (BNU_CHUNK_T*)(ptr); ptr += ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T);
- ECP_PREMULBP(pEC) = (cpPrecompAP*)NULL;
- ECP_MONT_R(pEC) = (gsModEngine*)( IPP_ALIGNED_PTR((ptr), (MONT_ALIGNMENT)) ); ptr += modEngineCtxSize;
- ECP_COFACTOR(pEC) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T);
- #if defined(_LEGACY_ECCP_SUPPORT_)
- ECP_PUBLIC(pEC) = (BNU_CHUNK_T*)(ptr); ptr += 3*elemLen*sizeof(BNU_CHUNK_T);
- ECP_PUBLIC_E(pEC) = (BNU_CHUNK_T*)(ptr); ptr += 3*elemLen*sizeof(BNU_CHUNK_T);
- ECP_PRIVAT(pEC) = (BNU_CHUNK_T*)(ptr); ptr += maxOrdLen*sizeof(BNU_CHUNK_T);
- ECP_PRIVAT_E(pEC) = (BNU_CHUNK_T*)(ptr); ptr += maxOrdLen*sizeof(BNU_CHUNK_T);
- ECP_SBUFFER(pEC) = (BNU_CHUNK_T*)0;
- #endif
- ECP_POOL(pEC) = (BNU_CHUNK_T*)(ptr); //ptr += ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T)*EC_POOL_SIZE;
-
- cpGFpElementPadd(ECP_A(pEC), elemLen, 0);
- cpGFpElementPadd(ECP_B(pEC), elemLen, 0);
- cpGFpElementPadd(ECP_G(pEC), elemLen*3, 0);
- gsModEngineInit(ECP_MONT_R(pEC), NULL, maxOrderBits, MONT_DEFAULT_POOL_LENGTH, gsModArithMont());
-
- cpGFpElementPadd(ECP_COFACTOR(pEC), elemLen, 0);
-
- cpGFpElementPadd(ECP_POOL(pEC), elemLen*3*EC_POOL_SIZE, 0);
-
- /* set up EC if possible */
- if(pA && pB)
- return ippsGFpECSet(pA,pB, pEC);
- else
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECSet,(const IppsGFpElement* pA,
- const IppsGFpElement* pB,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- IPP_BAD_PTR2_RET(pA, pB);
- IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(ECP_GFP(pEC));
- int elemLen = GFP_FELEN(pGFE);
-
- IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- IPP_BADARG_RET( GFPE_ROOM(pB)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- /* copy A */
- cpGFpElementPadd(ECP_A(pEC), elemLen, 0);
- cpGFpElementCopy(ECP_A(pEC), GFPE_DATA(pA), elemLen);
- /* and set up A-specific (a==0 or a==-3) if is */
- if(GFP_IS_ZERO(ECP_A(pEC), elemLen))
- ECP_SPECIFIC(pEC) = ECP_EPID2;
-
- cpGFpElementSetChunk(ECP_B(pEC), elemLen, 3);
- GFP_METHOD(pGFE)->encode(ECP_B(pEC), ECP_B(pEC), pGFE);
- GFP_METHOD(pGFE)->add(ECP_B(pEC), ECP_A(pEC), ECP_B(pEC), pGFE);
- if(GFP_IS_ZERO(ECP_B(pEC), elemLen))
- ECP_SPECIFIC(pEC) = ECP_STD;
-
- /* copy B */
- cpGFpElementPadd(ECP_B(pEC), elemLen, 0);
- cpGFpElementCopy(ECP_B(pEC), GFPE_DATA(pB), elemLen);
- /* and set type of affine infinity representation:
- // (0,1) if B==0
- // (0,0) if B!=0 */
- ECP_INFINITY(pEC) = GFP_IS_ZERO(ECP_B(pEC), elemLen);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECSetSubgroup,(const IppsGFpElement* pX, const IppsGFpElement* pY,
- const IppsBigNumState* pOrder,
- const IppsBigNumState* pCofactor,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- IPP_BAD_PTR2_RET(pX, pY);
- IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
-
- IPP_BAD_PTR2_RET(pOrder, pCofactor);
- pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_SIGN(pOrder)!= IppsBigNumPOS, ippStsBadArgErr);
-
- pCofactor = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCofactor, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCofactor), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_SIGN(pCofactor)!= IppsBigNumPOS, ippStsBadArgErr);
-
- {
- gsModEngine* pGFE = GFP_PMA(ECP_GFP(pEC));
- int elemLen = GFP_FELEN(pGFE);
-
- IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- gfec_SetPoint(ECP_G(pEC), GFPE_DATA(pX), GFPE_DATA(pY), pEC);
-
- {
- int maxOrderBits = 1+ cpGFpBasicDegreeExtension(pGFE) * GFP_FEBITLEN(cpGFpBasic(pGFE));
- BNU_CHUNK_T* pOrderData = BN_NUMBER(pOrder);
- int orderLen= BN_SIZE(pOrder);
- int orderBitSize = BITSIZE_BNU(pOrderData, orderLen);
- IPP_BADARG_RET(orderBitSize>maxOrderBits, ippStsRangeErr)
- ECP_ORDBITSIZE(pEC) = orderBitSize;
- gsModEngineInit(ECP_MONT_R(pEC),(Ipp32u*)pOrderData, orderBitSize, MONT_DEFAULT_POOL_LENGTH, gsModArithMont());
- }
-
- {
- BNU_CHUNK_T* pCofactorData = BN_NUMBER(pCofactor);
- int cofactorLen= BN_SIZE(pCofactor);
- int cofactorBitSize = BITSIZE_BNU(pCofactorData, cofactorLen);
- IPP_BADARG_RET(cofactorBitSize>elemLen*BITSIZE(BNU_CHUNK_T), ippStsRangeErr)
- COPY_BNU(ECP_COFACTOR(pEC), pCofactorData, cofactorLen);
- }
-
- return ippStsNoErr;
- }
-}
-
-
-static void cpGFpECSetStd(int aLen, const BNU_CHUNK_T* pA,
- int bLen, const BNU_CHUNK_T* pB,
- int xLen, const BNU_CHUNK_T* pX,
- int yLen, const BNU_CHUNK_T* pY,
- int rLen, const BNU_CHUNK_T* pR,
- BNU_CHUNK_T h,
- IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- IppsGFpElement elmA, elmB;
- IppsBigNumState R, H;
-
- /* convert A ans B coeffs into GF elements */
- cpGFpElementConstruct(&elmA, cpGFpGetPool(1, pGFE), elemLen);
- cpGFpElementConstruct(&elmB, cpGFpGetPool(1, pGFE), elemLen);
- ippsGFpSetElement((Ipp32u*)pA, BITS2WORD32_SIZE(BITSIZE_BNU(pA,aLen)), &elmA, pGF);
- ippsGFpSetElement((Ipp32u*)pB, BITS2WORD32_SIZE(BITSIZE_BNU(pB,bLen)), &elmB, pGF);
- /* and set EC */
- ippsGFpECSet(&elmA, &elmB, pEC);
-
- /* construct R and H */
- cpConstructBN(&R, rLen, (BNU_CHUNK_T*)pR, NULL);
- cpConstructBN(&H, 1, &h, NULL);
- /* convert GX ans GY coeffs into GF elements */
- ippsGFpSetElement((Ipp32u*)pX, BITS2WORD32_SIZE(BITSIZE_BNU(pX,xLen)), &elmA, pGF);
- ippsGFpSetElement((Ipp32u*)pY, BITS2WORD32_SIZE(BITSIZE_BNU(pY,yLen)), &elmB, pGF);
- /* and init EC subgroup */
- ippsGFpECSetSubgroup(&elmA, &elmB, &R, &H, pEC);
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd128r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp128r1_p, BITS_BNU_CHUNK(128), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(128)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(128), secp128r1_a,
- BITS_BNU_CHUNK(128), secp128r1_b,
- BITS_BNU_CHUNK(128), secp128r1_gx,
- BITS_BNU_CHUNK(128), secp128r1_gy,
- BITS_BNU_CHUNK(128), secp128r1_r,
- secp128r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd128r2,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp128r2_p, BITS_BNU_CHUNK(128), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(128)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(128), secp128r2_a,
- BITS_BNU_CHUNK(128), secp128r2_b,
- BITS_BNU_CHUNK(128), secp128r2_gx,
- BITS_BNU_CHUNK(128), secp128r2_gy,
- BITS_BNU_CHUNK(128), secp128r2_r,
- secp128r2_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd192r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp192r1_p, BITS_BNU_CHUNK(192), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(192)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(192), secp192r1_a,
- BITS_BNU_CHUNK(192), secp192r1_b,
- BITS_BNU_CHUNK(192), secp192r1_gx,
- BITS_BNU_CHUNK(192), secp192r1_gy,
- BITS_BNU_CHUNK(192), secp192r1_r,
- secp192r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd224r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp224r1_p, BITS_BNU_CHUNK(224), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(224)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(224), secp224r1_a,
- BITS_BNU_CHUNK(224), secp224r1_b,
- BITS_BNU_CHUNK(224), secp224r1_gx,
- BITS_BNU_CHUNK(224), secp224r1_gy,
- BITS_BNU_CHUNK(224), secp224r1_r,
- secp224r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd256r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp256r1_p, BITS_BNU_CHUNK(256), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(256)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(256), secp256r1_a,
- BITS_BNU_CHUNK(256), secp256r1_b,
- BITS_BNU_CHUNK(256), secp256r1_gx,
- BITS_BNU_CHUNK(256), secp256r1_gy,
- BITS_BNU_CHUNK(256), secp256r1_r,
- secp256r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd384r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp384r1_p, BITS_BNU_CHUNK(384), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(384)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(384), secp384r1_a,
- BITS_BNU_CHUNK(384), secp384r1_b,
- BITS_BNU_CHUNK(384), secp384r1_gx,
- BITS_BNU_CHUNK(384), secp384r1_gy,
- BITS_BNU_CHUNK(384), secp384r1_r,
- secp384r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStd521r1,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(secp521r1_p, BITS_BNU_CHUNK(521), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(521)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(521), secp521r1_a,
- BITS_BNU_CHUNK(521), secp521r1_b,
- BITS_BNU_CHUNK(521), secp521r1_gx,
- BITS_BNU_CHUNK(521), secp521r1_gy,
- BITS_BNU_CHUNK(521), secp521r1_r,
- secp521r1_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStdSM2,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(tpmSM2_p256_p, BITS_BNU_CHUNK(256), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(256)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(256), tpmSM2_p256_a,
- BITS_BNU_CHUNK(256), tpmSM2_p256_b,
- BITS_BNU_CHUNK(256), tpmSM2_p256_gx,
- BITS_BNU_CHUNK(256), tpmSM2_p256_gy,
- BITS_BNU_CHUNK(256), tpmSM2_p256_r,
- tpmSM2_p256_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECInitStdBN256,(const IppsGFpState* pGF, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pGF, pEC);
-
- pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr );
-
- {
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(tpmBN_p256p_p, BITS_BNU_CHUNK(256), GFP_MODULUS(pGFE), BITS_BNU_CHUNK(256)), ippStsBadArgErr);
-
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
-
- ippsGFpECInit(pGF, NULL, NULL, pEC);
- cpGFpECSetStd(BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_a,
- BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_b,
- BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_gx,
- BITS_BNU_CHUNK(BNU_CHUNK_BITS), tpmBN_p256p_gy,
- BITS_BNU_CHUNK(256), tpmBN_p256p_r,
- tpmBN_p256p_h,
- pEC);
-
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECGet,(IppsGFpState** const ppGF,
- IppsGFpElement* pA, IppsGFpElement* pB,
- const IppsGFpECState* pEC))
-{
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- {
- const IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- Ipp32u elementSize = GFP_FELEN(pGFE);
-
- if(ppGF) {
- *ppGF = (IppsGFpState*)pGF;
- }
-
- if(pA) {
- IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr );
- IPP_BADARG_RET( GFPE_ROOM(pA)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- cpGFpElementCopy(GFPE_DATA(pA), ECP_A(pEC), elementSize);
- }
- if(pB) {
- IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr );
- IPP_BADARG_RET( GFPE_ROOM(pB)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- cpGFpElementCopy(GFPE_DATA(pB), ECP_B(pEC), elementSize);
- }
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECGetSubgroup,(IppsGFpState** const ppGF,
- IppsGFpElement* pX, IppsGFpElement* pY,
- IppsBigNumState* pOrder,
- IppsBigNumState* pCofactor,
- const IppsGFpECState* pEC))
-{
- IPP_BAD_PTR1_RET(pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- {
- const IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- Ipp32u elementSize = GFP_FELEN(pGFE);
-
- if(ppGF) {
- *ppGF = (IppsGFpState*)pGF;
- }
-
- if(pX) {
- IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- cpGFpElementCopy(GFPE_DATA(pX), ECP_G(pEC), elementSize);
- }
- if(pY) {
- IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
- IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
- cpGFpElementCopy(GFPE_DATA(pY), ECP_G(pEC)+elementSize, elementSize);
- }
-
- if(pOrder) {
- BNU_CHUNK_T* pOrderData = MOD_MODULUS(ECP_MONT_R(pEC));
- int orderBitSize = ECP_ORDBITSIZE(pEC);
- int orderLen = BITS_BNU_CHUNK(orderBitSize);
- FIX_BNU(pOrderData, orderLen);
-
- pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pOrder) < orderLen, ippStsLengthErr);
-
- ZEXPAND_COPY_BNU(BN_NUMBER(pOrder), BN_ROOM(pOrder), pOrderData, orderLen);
- BN_SIZE(pOrder) = orderLen;
- BN_SIGN(pOrder) = ippBigNumPOS;
- }
-
- if(pCofactor) {
- BNU_CHUNK_T* pCofactorData = ECP_COFACTOR(pEC);
- int cofactorLen = elementSize;
- FIX_BNU(pCofactorData, cofactorLen);
-
- pCofactor = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCofactor, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCofactor), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pCofactor) < cofactorLen, ippStsLengthErr);
-
- ZEXPAND_COPY_BNU(BN_NUMBER(pCofactor), BN_ROOM(pCofactor), pCofactorData, cofactorLen);
- BN_SIZE(pCofactor) = cofactorLen;
- BN_SIGN(pCofactor) = ippBigNumPOS;
- }
-
- return ippStsNoErr;
- }
-}
-
-static IppStatus cpGFpECBindGxyTbl(const BNU_CHUNK_T* pPrime,
- const cpPrecompAP* preComp,
- IppsGFpECState* pEC)
-{
- IPP_BAD_PTR1_RET(pEC);
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- {
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- Ipp32u elemLen = GFP_FELEN(pGFE);
-
- /* test if GF is prime GF */
- IPP_BADARG_RET(!GFP_IS_BASIC(pGFE), ippStsBadArgErr);
- /* test underlying prime value*/
- IPP_BADARG_RET(cpCmp_BNU(pPrime, elemLen, GFP_MODULUS(pGFE), elemLen), ippStsBadArgErr);
-
- {
- BNU_CHUNK_T* pbp_ec = ECP_G(pEC);
- int cmpFlag;
- BNU_CHUNK_T* pbp_tbl = cpEcGFpGetPool(1, pEC);
-
- selectAP select_affine_point = preComp->select_affine_point;
- const BNU_CHUNK_T* pTbl = preComp->pTbl;
- select_affine_point(pbp_tbl, pTbl, 1);
-
- /* check if EC's and G-table's Base Point is the same */
- cmpFlag = cpCmp_BNU(pbp_ec, elemLen*2, pbp_tbl, elemLen*2);
-
- cpEcGFpReleasePool(1, pEC);
-
- return cmpFlag? ippStsBadArgErr : ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStd192r1,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(secp192r1_p, gfpec_precom_nistP192r1_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_nistP192r1_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStd224r1,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(secp224r1_p, gfpec_precom_nistP224r1_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_nistP224r1_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStd256r1,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(secp256r1_p, gfpec_precom_nistP256r1_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_nistP256r1_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStd384r1,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(secp384r1_p, gfpec_precom_nistP384r1_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_nistP384r1_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStd521r1,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(secp521r1_p, gfpec_precom_nistP521r1_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_nistP521r1_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECBindGxyTblStdSM2,(IppsGFpECState* pEC))
-{
- IppStatus sts = cpGFpECBindGxyTbl(tpmSM2_p256_p, gfpec_precom_sm2_fun(), pEC);
-
- /* setup pre-computed g-table and point access function */
- if(ippStsNoErr==sts)
- ECP_PREMULBP(pEC) = gfpec_precom_sm2_fun();
-
- return sts;
-}
-
-IPPFUN(IppStatus, ippsGFpECScratchBufferSize,(int nScalars, const IppsGFpECState* pEC, int* pBufferSize))
-{
- IPP_BAD_PTR2_RET(pEC, pBufferSize);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- IPP_BADARG_RET( (0>=nScalars)||(nScalars>IPP_MAX_EXPONENT_NUM), ippStsBadArgErr);
-
- {
- /* select constant size of window */
- const int w = 5;
- /* number of table entries */
- const int nPrecomputed = 1<<(w-1); /* because of signed digit representation of scalar is uses */
-
- int pointDataSize = ECP_POINTLEN(pEC)*sizeof(BNU_CHUNK_T);
-
- *pBufferSize = nScalars * pointDataSize*nPrecomputed + CACHE_LINE_SIZE;
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECVerify,(IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR3_RET(pEC, pResult, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- *pResult = ippECValid;
-
- {
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
- mod_add addF = GFP_METHOD(pGFE)->add;
-
- /*
- // check discriminant ( 4*A^3 + 27*B^2 != 0 mod P)
- */
- if(ippECValid == *pResult) {
- BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pU = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(NULL!=pT && NULL!=pU);
-
- if(ECP_SPECIFIC(pEC)==ECP_EPID2)
- cpGFpElementPadd(pT, elemLen, 0); /* T = 4*A^3 = 0 */
- else {
- addF(pT, ECP_A(pEC), ECP_A(pEC), pGFE); /* T = 4*A^3 */
- sqrF(pT, pT, pGFE);
- mulF(pT, ECP_A(pEC), pT, pGFE);
- }
-
- addF(pU, ECP_B(pEC), ECP_B(pEC), pGFE); /* U = 9*B^2 */
- addF(pU, pU, ECP_B(pEC), pGFE);
- sqrF(pU, pU, pGFE);
-
- addF(pT, pU, pT, pGFE); /* T += 3*U */
- addF(pT, pU, pT, pGFE);
- addF(pT, pU, pT, pGFE);
-
- *pResult = GFP_IS_ZERO(pT, elemLen)? ippECIsZeroDiscriminant: ippECValid;
-
- cpGFpReleasePool(2, pGFE);
- }
-
- /*
- // check base point and it order
- */
- if(ippECValid == *pResult) {
- IppsGFpECPoint G;
- cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
-
- /* check G != infinity */
- *pResult = gfec_IsPointAtInfinity(&G)? ippECPointIsAtInfinite : ippECValid;
-
- /* check G lies on EC */
- if(ippECValid == *pResult)
- *pResult = gfec_IsPointOnCurve(&G, pEC)? ippECValid : ippECPointIsNotValid;
-
- /* check Gorder*G = infinity */
- if(ippECValid == *pResult) {
- IppsGFpECPoint T;
- cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
-
- //gfec_MulPoint(&T, &G, MNT_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer);
- gfec_MulBasePoint(&T, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer);
-
- *pResult = gfec_IsPointAtInfinity(&T)? ippECValid : ippECInvalidOrder;
-
- cpEcGFpReleasePool(1, pEC);
- }
- }
-
- /*
- // check order==P
- */
- if(ippECValid == *pResult) {
- BNU_CHUNK_T* pPrime = GFP_MODULUS(pGFE);
- int primeLen = GFP_FELEN(pGFE);
-
- gsModEngine* pR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pR);
- int orderLen = MOD_LEN(pR);
-
- *pResult = (primeLen==orderLen && GFP_EQ(pPrime, pOrder, primeLen))? ippECIsWeakSSSA : ippECValid;
- }
-
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecdh.c b/ext/ipp/sources/ippcp/src/pcpgfpecdh.c
deleted file mode 100644
index 797e8f6..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecdh.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over GF(p^m) Shared Secret (Diffie-Hellman wo/w cofactor)
-//
-// Contents:
-// ippsGFpECSharedSecretDH()
-// ippsGFpECSharedSecretDHC()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpecstuff.h"
-
-
-/*F*
-// Name: ippsGFpECSharedSecretDHC
-//
-// Purpose: Compute Shared Secret (Diffie-Hellman)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pPrivateA
-// NULL == pPublicB
-// NULL == pShare
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pPrivateA->idCtx
-// illegal pPublicB->idCtx
-// illegal pShare->idCtx
-//
-// ippStsRangeErr not enough room for share key
-//
-// ippStsShareKeyErr (infinity) => z
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivateA pointer to own private key
-// pPublicB pointer to alien public key
-// pShare pointer to the shared secret value
-// pEC pointer to the EC context
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECSharedSecretDH,(const IppsBigNumState* pPrivateA, const IppsGFpECPoint* pPublicB,
- IppsBigNumState* pShare,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- /* test private (own) key */
- IPP_BAD_PTR1_RET(pPrivateA);
- pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr);
-
- /* test public (other party) key */
- IPP_BAD_PTR1_RET(pPublicB);
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublicB), ippStsContextMatchErr );
-
- /* test share secret value */
- IPP_BAD_PTR1_RET(pShare);
- pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pShare)<GFP_FELEN(pGFE)), ippStsRangeErr);
-
- {
- int elmLen = GFP_FELEN(pGFE);
-
- IppsGFpElement elm;
- IppsGFpECPoint T;
- int finite_point;
-
- /* T = [privateA]pPublicB */
- cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
- gfec_MulPoint(&T, pPublicB, BN_NUMBER(pPrivateA), BN_SIZE(pPrivateA), pEC, pScratchBuffer);
-
- /* share = T.x */
- cpGFpElementConstruct(&elm, cpGFpGetPool(1, pGFE), elmLen);
- finite_point = gfec_GetPoint(GFPE_DATA(&elm), NULL, &T, pEC);
-
- if(finite_point) {
- BNU_CHUNK_T* pShareData = BN_NUMBER(pShare);
- int nsShare = BN_ROOM(pShare);
- /* share = decode(T.x) */
- GFP_METHOD(pGFE)->decode(pShareData, GFPE_DATA(&elm), pGFE);
- cpGFpElementPadd(pShareData+elmLen, nsShare-elmLen, 0);
-
- BN_SIGN(pShare) = ippBigNumPOS;
- FIX_BNU(pShareData, nsShare);
- BN_SIZE(pShare) = nsShare;
- }
-
- cpGFpReleasePool(1, pGFE);
- cpEcGFpReleasePool(1, pEC);
-
- return finite_point? ippStsNoErr : ippStsShareKeyErr;
- }
-}
-
-
-/*F*
-// Name: ippsGFpECSharedSecretDHC
-//
-// Purpose: Compute Shared Secret (Diffie-Hellman with cofactor)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pPrivateA
-// NULL == pPublicB
-// NULL == pShare
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pPrivateA->idCtx
-// illegal pPublicB->idCtx
-// illegal pShare->idCtx
-//
-// ippStsRangeErr not enough room for share key
-//
-// ippStsShareKeyErr (infinity) => z
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivateA pointer to own private key
-// pPublicB pointer to alien public key
-// pShare pointer to the shared secret value
-// pEC pointer to the EC context
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECSharedSecretDHC,(const IppsBigNumState* pPrivateA, const IppsGFpECPoint* pPublicB,
- IppsBigNumState* pShare,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- /* test private (own) key */
- IPP_BAD_PTR1_RET(pPrivateA);
- pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr);
-
- /* test public (other party) key */
- IPP_BAD_PTR1_RET(pPublicB);
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublicB), ippStsContextMatchErr );
-
- /* test share key */
- IPP_BAD_PTR1_RET(pShare);
- pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pShare)<GFP_FELEN(pGFE)), ippStsRangeErr);
-
- {
- int elmLen = GFP_FELEN(pGFE);
-
- IppsGFpElement elm;
- IppsGFpECPoint T;
- int finite_point;
-
- gsModEngine* montR = ECP_MONT_R(pEC);
- int nsR = MOD_LEN(montR);
-
- /* compute factored secret F = coFactor*privateA */
- BNU_CHUNK_T* F = cpGFpGetPool(1, pGFE);
- cpMontEnc_BNU_EX(F, BN_NUMBER(pPrivateA), BN_SIZE(pPrivateA), montR);
- cpMontMul_BNU_EX(F, F, nsR, ECP_COFACTOR(pEC), 1, montR);
-
- /* T = [F]pPublicB */
- cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
- FIX_BNU(F, nsR);
- gfec_MulPoint(&T, pPublicB, F, nsR, pEC, pScratchBuffer);
-
- /* share = T.x */
- cpGFpElementConstruct(&elm, F, elmLen);
- finite_point = gfec_GetPoint(GFPE_DATA(&elm), NULL, &T, pEC);
- if(finite_point) {
- BNU_CHUNK_T* pShareData = BN_NUMBER(pShare);
- int nsShare = BN_ROOM(pShare);
- /* share = decode(T.x) */
- GFP_METHOD(pGFE)->decode(pShareData, GFPE_DATA(&elm), pGFE);
- cpGFpElementPadd(pShareData+elmLen, nsShare-elmLen, 0);
-
- BN_SIGN(pShare) = ippBigNumPOS;
- FIX_BNU(pShareData, nsShare);
- BN_SIZE(pShare) = nsShare;
- }
-
- cpGFpReleasePool(1, pGFE);
- cpEcGFpReleasePool(1, pEC);
-
- return finite_point? ippStsNoErr : ippStsShareKeyErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpeckeys.c b/ext/ipp/sources/ippcp/src/pcpgfpeckeys.c
deleted file mode 100644
index c53b47a..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpeckeys.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// EC over GF(p^m) Public Key Generation and Test KeyPair
-//
-// Contents:
-// ippsGFpECPrivateKey()
-// ippsGFpECPublicKey()
-// ippsGFpECTstKeyPair()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpecstuff.h"
-
-
-/*F*
-// Name: ippsGFpECPrivateKey
-//
-// Purpose: Generate random private key
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pPrivate
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pPrivate->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the resultant private key
-// pEC pointer to the EC context
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECPrivateKey, (IppsBigNumState* pPrivate, IppsGFpECState* pEC,
- IppBitSupplier rndFunc, void* pRndParam))
-{
- IPP_BAD_PTR2_RET(pEC, rndFunc);
-
- /* use aligned EC context */
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test private key */
- IPP_BAD_PTR1_RET(pPrivate);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pPrivate)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsSizeErr);
-
- {
- /* generate random private key X: 0 < X < R */
- BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
- int orderBitLen = ECP_ORDBITSIZE(pEC);
- int orderLen = BITS_BNU_CHUNK(orderBitLen);
-
- BNU_CHUNK_T* pX = BN_NUMBER(pPrivate);
- int nsX = BITS_BNU_CHUNK(orderBitLen);
- BNU_CHUNK_T xMask = MASK_BNU_CHUNK(orderBitLen);
-
- IppStatus sts;
- do {
- sts = rndFunc((Ipp32u*)pX, orderBitLen, pRndParam);
- if(ippStsNoErr!=sts)
- break;
- pX[nsX-1] &= xMask;
- } while( (1 == cpEqu_BNU_CHUNK(pX, nsX, 0)) ||
- (0 <= cpCmp_BNU(pX, nsX, pOrder, orderLen)) );
-
- /* set up private */
- if(ippStsNoErr==sts) {
- BN_SIGN(pPrivate) = ippBigNumPOS;
- FIX_BNU(pX, nsX);
- BN_SIZE(pPrivate) = nsX;
- }
-
- return sts;
- }
-}
-
-
-/*F*
-// Name: ippsGFpECPublicKey
-//
-// Purpose: Compute Public Key
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pPrivate
-// NULL == pPublic
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pPrivate->idCtx
-// illegal pPublic->idCtx
-//
-// ippStsIvalidPrivateKey !(0 < pPrivate < order)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the private key
-// pPublic pointer to the resultant public key
-// pEC pointer to the EC context
-// pScratchBuffer pointer to buffer (1 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECPublicKey, (const IppsBigNumState* pPrivate, IppsGFpECPoint* pPublic,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-{
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test private keys */
- IPP_BAD_PTR1_RET(pPrivate);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
-
- /* test public key */
- IPP_BAD_PTR1_RET(pPublic);
- IPP_BADARG_RET(!ECP_POINT_TEST_ID(pPublic), ippStsContextMatchErr);
- IPP_BADARG_RET(ECP_POINT_FELEN(pPublic)<GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsRangeErr);
-
- {
- BNU_CHUNK_T* pS= BN_NUMBER(pPrivate);
- int nsS= BN_SIZE(pPrivate);
-
- BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
- int orderLen = BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC));
-
- IPP_BADARG_RET(cpEqu_BNU_CHUNK(pS, nsS, 0)
- || 0<=cpCmp_BNU(pS, nsS, pOrder, orderLen), ippStsIvalidPrivateKey);
-
- /* calculates public key */
- gfec_MulBasePoint(pPublic, pS, nsS, pEC, pScratchBuffer);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsGFpECTstKeyPair
-//
-// Purpose: Test Key Pair
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pPrivate
-// NULL == pPublic
-// NULL == pResult
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pPrivate->idCtx
-// illegal pPublic->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the private key
-// pPublic pointer to the public key
-// pResult pointer to the result:
-// ippECValid/ippECInvalidPrivateKey/ippECPointIsAtInfinite/ippECInvalidPublicKey
-// pEC pointer to the EC context
-// pScratchBuffer pointer to buffer (1 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECTstKeyPair, (const IppsBigNumState* pPrivate, const IppsGFpECPoint* pPublic, IppECResult* pResult,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer))
-{
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- /* test result */
- IPP_BAD_PTR1_RET(pResult);
- *pResult = ippECValid;
-
- /* private key validation request */
- if( pPrivate ) {
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
-
- {
- BNU_CHUNK_T* pS = BN_NUMBER(pPrivate);
- int nsS = BN_SIZE(pPrivate);
-
- BNU_CHUNK_T* pOrder = MOD_MODULUS(ECP_MONT_R(pEC));
- int orderLen = BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC));
-
- /* check private key */
- if(cpEqu_BNU_CHUNK(pS, nsS, 0) || 0<=cpCmp_BNU(pS, nsS, pOrder, orderLen)) {
- *pResult = ippECInvalidPrivateKey;
- return ippStsNoErr;
- }
- }
- }
-
- /* public key validation request */
- if( pPublic ) {
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPublic), ippStsContextMatchErr );
- IPP_BADARG_RET(ECP_POINT_FELEN(pPublic)<GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsRangeErr);
-
- {
- IppsGFpECPoint T;
- cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
-
- do {
- /* public != point_at_Infinity */
- if( gfec_IsPointAtInfinity(pPublic) ) {
- *pResult = ippECPointIsAtInfinite;
- break;
- }
- /* order*public == point_at_Infinity */
- gfec_MulPoint(&T, pPublic, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer);
- if( !gfec_IsPointAtInfinity(&T) ) {
- *pResult = ippECInvalidPublicKey;
- break;
- }
- /* addition test: private*BasePoint == public */
- if(pPrivate) {
- gfec_MulBasePoint(&T, BN_NUMBER(pPrivate), BN_SIZE(pPrivate), pEC, pScratchBuffer);
- if(!gfec_ComparePoint(&T, pPublic, pEC))
- *pResult = ippECInvalidKeyPair;
- }
- } while(0);
-
- cpEcGFpReleasePool(1, pEC);
- }
- }
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecpoint.c b/ext/ipp/sources/ippcp/src/pcpgfpecpoint.c
deleted file mode 100644
index 574d76f..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecpoint.c
+++ /dev/null
@@ -1,643 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// EC over GF(p) Operations
-//
-// Context:
-// ippsGFpECPointGetSize()
-// ippsGFpECPointInit()
-//
-// ippsGFpECSetPointAtInfinity()
-// ippsGFpECSetPoint()
-// ippsGFpECSetPointRegular()
-// ippsGFpECMakePoint()
-// ippsGFpECSetPointRandom()
-// ippsGFpECSetPointHash()
-// ippsGFpECSetPointHash_rmf()
-// ippsGFpECGetPoint()
-// ippsGFpECGetPointRegular()
-// ippsGFpECCpyPoint()
-//
-// ippsGFpECCmpPoint()
-// ippsGFpECTstPoint()
-// ippsGFpECNegPoint()
-// ippsGFpECAddPoint()
-// ippsGFpECMulPoint()
-//
-//
-*/
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpecstuff.h"
-#include "pcphash.h"
-#include "pcphash_rmf.h"
-
-
-IPPFUN(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSizeInBytes))
-{
- IPP_BAD_PTR2_RET(pEC, pSizeInBytes);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- {
- int elemLen = GFP_FELEN(GFP_PMA(ECP_GFP(pEC)));
- *pSizeInBytes = sizeof(IppsGFpECPoint)
- +elemLen*sizeof(BNU_CHUNK_T) /* X */
- +elemLen*sizeof(BNU_CHUNK_T) /* Y */
- +elemLen*sizeof(BNU_CHUNK_T);/* Z */
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECPointInit,(const IppsGFpElement* pX, const IppsGFpElement* pY,
- IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- {
- Ipp8u* ptr = (Ipp8u*)pPoint;
- int elemLen = GFP_FELEN(GFP_PMA(ECP_GFP(pEC)));
-
- ECP_POINT_ID(pPoint) = idCtxGFPPoint;
- ECP_POINT_FLAGS(pPoint) = 0;
- ECP_POINT_FELEN(pPoint) = elemLen;
- ptr += sizeof(IppsGFpECPoint);
- ECP_POINT_DATA(pPoint) = (BNU_CHUNK_T*)(ptr);
-
- if(pX && pY)
- return ippsGFpECSetPoint(pX, pY, pPoint, pEC);
- else {
- gfec_SetPointAtInfinity(pPoint);
- return ippStsNoErr;
- }
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECSetPointAtInfinity,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- gfec_SetPointAtInfinity(pPoint);
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECSetPoint,(const IppsGFpElement* pX, const IppsGFpElement* pY,
- IppsGFpECPoint* pPoint,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BAD_PTR2_RET(pX, pY);
- IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr );
-
- IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( GFPE_ROOM(pY)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- if(gfec_SetPoint(ECP_POINT_DATA(pPoint), GFPE_DATA(pX), GFPE_DATA(pY), pEC))
- ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
- else
- ECP_POINT_FLAGS(pPoint) = 0;
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECSetPointRegular,(const IppsBigNumState* pX, const IppsBigNumState* pY,
- IppsGFpECPoint* pPoint,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BAD_PTR2_RET(pX, pY);
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, BN_ALIGNMENT) );
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, BN_ALIGNMENT) );
- IPP_BADARG_RET( !BN_VALID_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( !BN_VALID_ID(pY), ippStsContextMatchErr );
- IPP_BADARG_RET( !BN_POSITIVE(pX), ippStsOutOfRangeErr);
- IPP_BADARG_RET( !BN_POSITIVE(pY), ippStsOutOfRangeErr);
-
- {
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr )
-
- IPP_BADARG_RET( BN_SIZE(pX) > elemLen, ippStsOutOfRangeErr);
- IPP_BADARG_RET( BN_SIZE(pY) > elemLen, ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=elemLen, ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pointX = ECP_POINT_X(pPoint);
- BNU_CHUNK_T* pointY = ECP_POINT_Y(pPoint);
- BNU_CHUNK_T* pointZ = ECP_POINT_Z(pPoint);
-
- cpGFpElementCopyPadd(pointX, elemLen, BN_NUMBER(pX), BN_SIZE(pX));
- cpGFpElementCopyPadd(pointY, elemLen, BN_NUMBER(pY), BN_SIZE(pY));
- cpGFpElementCopy(pointZ, MOD_MNT_R(pGFE), elemLen);
-
- if( cpGFpSet(pointX, pointX, elemLen, pGFE) && cpGFpSet(pointY, pointY, elemLen, pGFE) )
- ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
- else
- gfec_SetPointAtInfinity(pPoint);
-
- return ippStsNoErr;
- }
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECGetPoint,(const IppsGFpECPoint* pPoint,
- IppsGFpElement* pX, IppsGFpElement* pY,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- ///IPP_BADARG_RET( !IS_ECP_FINITE_POINT(pPoint), ippStsPointAtInfinity);
-
- IPP_BADARG_RET( pX && !GFPE_TEST_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( pY && !GFPE_TEST_ID(pY), ippStsContextMatchErr );
-
- IPP_BADARG_RET( pX && GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( pY && GFPE_ROOM(pY)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- /* returns (X,Y) == (0,0) if Point is at infinity */
- gfec_GetPoint((pX)? GFPE_DATA(pX):NULL, (pY)? GFPE_DATA(pY):NULL, pPoint, pEC);
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECGetPointRegular,(const IppsGFpECPoint* pPoint,
- IppsBigNumState* pX, IppsBigNumState* pY,
- IppsGFpECState* pEC))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- IPP_BAD_PTR2_RET(pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- if(pX) {
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET(BN_ROOM(pX)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE), ippStsOutOfRangeErr);
- }
- if(pY) {
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr );
- IPP_BADARG_RET(BN_ROOM(pY)*BNU_CHUNK_BITS<GFP_FEBITLEN(pGFE), ippStsOutOfRangeErr);
- }
-
- {
- int elmLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* x = cpGFpGetPool(2, pGFE);
- BNU_CHUNK_T* y = x + elmLen;
-
- /* returns (X,Y) == (0,0) if Point is at infinity */
- gfec_GetPoint((pX)? x:NULL, (pY)? y:NULL, pPoint, pEC);
-
- /* convert into refular domain */
- if(pX) {
- GFP_METHOD(pGFE)->decode(x, x, pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)x, pX);
- }
- if(pY) {
- GFP_METHOD(pGFE)->decode(y, y, pGFE);
- ippsSet_BN(ippBigNumPOS, GFP_FELEN32(pGFE), (Ipp32u*)y, pY);
- }
-
- cpGFpReleasePool(2, pGFE);
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECMakePoint,(const IppsGFpElement* pX, IppsGFpECPoint* pPoint, IppsGFpECState* pEC))
-{
- IPP_BAD_PTR3_RET(pX, pPoint, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !GFP_IS_BASIC(GFP_PMA(ECP_GFP(pEC))), ippStsBadArgErr );
- IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BADARG_RET( GFPE_ROOM(pX)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- return gfec_MakePoint(pPoint, GFPE_DATA(pX), pEC)? ippStsNoErr : ippStsQuadraticNonResidueErr;
-}
-
-
-IPPFUN(IppStatus, ippsGFpECSetPointRandom,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC,
- IppBitSupplier rndFunc, void* pRndParam,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- IPP_BAD_PTR2_RET(rndFunc, pRndParam);
-
- {
- int internal_err;
-
- if( GFP_IS_BASIC(pGFE) ) {
- BNU_CHUNK_T* pElm = cpGFpGetPool(1, pGFE);
-
- do { /* get random X */
- internal_err = NULL==cpGFpRand(pElm, pGFE, rndFunc, pRndParam);
- } while( !internal_err && !gfec_MakePoint(pPoint, pElm, pEC) );
-
- cpGFpReleasePool(1, pGFE);
-
- /* R = [cofactor]R */
- if(!internal_err)
- gfec_MulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGFE), pEC, pScratchBuffer);
- }
-
- else {
- /* number of bits and dwords being generated */
- int generatedBits = ECP_ORDBITSIZE(pEC) + GFP_RAND_ADD_BITS;
- int generatedLen = BITS_BNU_CHUNK(generatedBits);
-
- /* allocate random exponent */
- int poolElements = (generatedLen + GFP_PELEN(pGFE) -1) / GFP_PELEN(pGFE);
- BNU_CHUNK_T* pExp = cpGFpGetPool(poolElements, pGFE);
- int nsE;
-
- /* setup copy of the base point */
- IppsGFpECPoint G;
- cpEcGFpInitPoint(&G, ECP_G(pEC),ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
-
- /* get random bits */
- internal_err = ippStsNoErr != rndFunc((Ipp32u*)pExp, generatedBits, pRndParam);
-
- if(!internal_err) {
- /* reduce with respect to order value */
- nsE = cpMod_BNU(pExp, generatedLen, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)));
- /* compute random point */
- gfec_MulPoint(pPoint, &G, pExp, nsE, pEC, pScratchBuffer);
- }
-
- cpGFpReleasePool(poolElements, pGFE);
- }
-
- return internal_err? ippStsErr : ippStsNoErr;
- }
-}
-
-
-
-IPPFUN(IppStatus, ippsGFpECCpyPoint,(const IppsGFpECPoint* pA,
- IppsGFpECPoint* pR,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR3_RET(pA, pR, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pA), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pA)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- gfec_CopyPoint(pR, pA, GFP_FELEN(GFP_PMA(ECP_GFP(pEC))));
- return ippStsNoErr;
-}
-
-
-IPPFUN(IppStatus, ippsGFpECCmpPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ,
- IppECResult* pResult,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR4_RET(pP, pQ, pResult, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pQ)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- *pResult = gfec_ComparePoint(pP, pQ, pEC)? ippECPointIsEqual : ippECPointIsNotEqual;
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP,
- IppECResult* pResult,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR3_RET(pP, pResult, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- if( gfec_IsPointAtInfinity(pP) )
- *pResult = ippECPointIsAtInfinite;
- else if( !gfec_IsPointOnCurve(pP, pEC) )
- *pResult = ippECPointIsNotValid;
- else
- *pResult = ippECValid;
-
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECTstPointInSubgroup,(const IppsGFpECPoint* pP,
- IppECResult* pResult,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR4_RET(pP, pResult, pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- {
- IppECResult tstResult;
- ippsGFpECTstPoint(pP, &tstResult, pEC);
-
- if(ippECValid==tstResult) {
- IppsGFpECPoint T;
- cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC);
-
- gfec_MulPoint(&T, pP, MOD_MODULUS(ECP_MONT_R(pEC)), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer);
- tstResult = gfec_IsPointAtInfinity(&T)? ippECValid : ippECPointOutOfGroup;
-
- cpEcGFpReleasePool(1, pEC);
- }
- *pResult = tstResult;
-
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsGFpECNegPoint,(const IppsGFpECPoint* pP,
- IppsGFpECPoint* pR,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR3_RET(pP, pR, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- gfec_NegPoint(pR, pP, pEC);
- return ippStsNoErr;
-}
-
-
-IPPFUN(IppStatus, ippsGFpECAddPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECPoint* pR,
- IppsGFpECState* pEC))
-{
- IPP_BAD_PTR4_RET(pP, pQ, pR, pEC);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pQ)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- if(pP==pQ)
- gfec_DblPoint(pR, pP, pEC);
- else
- gfec_AddPoint(pR, pP, pQ, pEC);
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECMulPoint,(const IppsGFpECPoint* pP,
- const IppsBigNumState* pN,
- IppsGFpECPoint* pR,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR4_RET(pP, pR, pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pP)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
- IPP_BADARG_RET( ECP_POINT_FELEN(pR)!=GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsOutOfRangeErr);
-
- IPP_BAD_PTR1_RET(pN);
- pN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pN), ippStsContextMatchErr );
- IPP_BADARG_RET( BN_NEGATIVE(pN), ippStsBadArgErr );
- IPP_BADARG_RET(BN_SIZE(pN)>2*GFP_FELEN(GFP_PMA(ECP_GFP(pEC))), ippStsSizeErr);
-
- gfec_MulPoint(pR, pP, BN_NUMBER(pN), BN_SIZE(pN), pEC, pScratchBuffer);
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsGFpECSetPointHash,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppsGFpECPoint* pPoint,
- IppsGFpECState* pEC, IppHashAlgId hashID,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* get algorithm id */
- hashID = cpValidHashAlg(hashID);
- IPP_BADARG_RET(ippHashAlg_Unknown==hashID, ippStsNotSupportedModeErr);
-
- /* test message length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- /* test message pointer */
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- {
- int elemLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
-
- Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
- int hashLen = cpHashAlgAttr[hashID].hashSize;
- BNU_CHUNK_T hashVal[BITS_BNU_CHUNK(IPP_SHA512_DIGEST_BITSIZE)+1];
- int hashValLen;
-
- IppsHashState hashCtx;
- ippsHashInit(&hashCtx, hashID);
-
- {
- BNU_CHUNK_T* pPoolElm = cpGFpGetPool(1, pGFE);
-
- /* convert hdr => hdrStr */
- BNU_CHUNK_T locHdr = (BNU_CHUNK_T)hdr;
- Ipp8u hdrOctStr[sizeof(hdr/*locHdr*/)];
- cpToOctStr_BNU(hdrOctStr, sizeof(hdrOctStr), &locHdr, 1);
-
- /* compute md = hash(hrd||msg) */
- ippsHashUpdate(hdrOctStr, sizeof(hdrOctStr), &hashCtx);
- ippsHashUpdate(pMsg, msgLen, &hashCtx);
- ippsHashFinal(md, &hashCtx);
-
- /* convert hash into the integer */
- hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
- hashValLen = cpMod_BNU(hashVal, hashValLen, pModulus, elemLen);
- cpGFpSet(pPoolElm, hashVal, hashValLen, pGFE);
-
- if( gfec_MakePoint(pPoint, pPoolElm, pEC)) {
- /* set y-coordinate of the point (positive or negative) */
- BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
- if(pY[0] & 1)
- cpGFpNeg(pY, pY, pGFE);
-
- /* update point if cofactor>1 */
- gfec_MulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGFE), pEC, pScratchBuffer);
-
- cpGFpReleasePool(1, pGFE);
- return ippStsNoErr;
- }
- }
-
- cpGFpReleasePool(1, pGFE);
- return ippStsQuadraticNonResidueErr;
- }
-}
-
-IPPFUN(IppStatus, ippsGFpECSetPointHash_rmf,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppsGFpECPoint* pPoint,
- IppsGFpECState* pEC, const IppsHashMethod* pMethod,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* test method pointer */
- IPP_BAD_PTR1_RET(pMethod);
-
- /* test message length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- /* test message pointer */
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- IPP_BAD_PTR3_RET(pPoint, pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr );
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
-
- IPP_BADARG_RET( !GFP_IS_BASIC(pGFE), ippStsBadArgErr );
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr );
-
- IPP_BADARG_RET( ECP_POINT_FELEN(pPoint)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- {
- int elemLen = GFP_FELEN(pGFE);
- BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
-
- Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
- int hashLen = pMethod->hashLen;
- BNU_CHUNK_T hashVal[BITS_BNU_CHUNK(IPP_SHA512_DIGEST_BITSIZE)+1];
- int hashValLen;
-
- IppsHashState_rmf hashCtx;
- ippsHashInit_rmf(&hashCtx, pMethod);
-
- {
- BNU_CHUNK_T* pPoolElm = cpGFpGetPool(1, pGFE);
-
- /* convert hdr => hdrStr */
- BNU_CHUNK_T locHdr = (BNU_CHUNK_T)hdr;
- Ipp8u hdrOctStr[sizeof(hdr/*locHdr*/)];
- cpToOctStr_BNU(hdrOctStr, sizeof(hdrOctStr), &locHdr, 1);
-
- /* compute md = hash(hrd||msg) */
- ippsHashUpdate_rmf(hdrOctStr, sizeof(hdrOctStr), &hashCtx);
- ippsHashUpdate_rmf(pMsg, msgLen, &hashCtx);
- ippsHashFinal_rmf(md, &hashCtx);
-
- /* convert hash into the integer */
- hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen);
- hashValLen = cpMod_BNU(hashVal, hashValLen, pModulus, elemLen);
- cpGFpSet(pPoolElm, hashVal, hashValLen, pGFE);
-
- if( gfec_MakePoint(pPoint, pPoolElm, pEC)) {
- /* set y-coordinate of the point (positive or negative) */
- BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
- if(pY[0] & 1)
- cpGFpNeg(pY, pY, pGFE);
-
- /* update point if cofactor>1 */
- gfec_MulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGFE), pEC, pScratchBuffer);
-
- cpGFpReleasePool(1, pGFE);
- return ippStsNoErr;
- }
- }
-
- cpGFpReleasePool(1, pGFE);
- return ippStsQuadraticNonResidueErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecpointstuff.c b/ext/ipp/sources/ippcp/src/pcpgfpecpointstuff.c
deleted file mode 100644
index 442362c..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecpointstuff.c
+++ /dev/null
@@ -1,1243 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// Internal EC over GF(p^m) basic Definitions & Function Prototypes
-//
-// Context:
-// gfec_MakePoint()
-// gfec_SetPoint
-// gfec_GetPoint
-//
-// gfec_ComparePoint()
-// gfec_IsPointOnCurve()
-//
-// gfec_NegPoint()
-// gfec_DblPoint()
-// gfec_AddPoint()
-// gfec_MulPoint()
-//
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpecstuff.h"
-#include "gsscramble.h"
-
-
-int gfec_MakePoint(IppsGFpECPoint* pPoint, const BNU_CHUNK_T* pElm, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
- mod_add addF = GFP_METHOD(pGFE)->add;
-
- BNU_CHUNK_T* pX = ECP_POINT_X(pPoint);
- BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
- BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint);
-
- /* set x-coordinate */
- cpGFpElementCopy(pX, pElm, elemLen);
-
- /* T = X^3 + A*X + B */
- sqrF(pY, pX, pGFE);
- mulF(pY, pY, pX, pGFE);
- if(ECP_SPECIFIC(pEC)!=ECP_EPID2) {
- mulF(pZ, ECP_A(pEC), pX, pGFE);
- addF(pY, pY, pZ, pGFE);
- }
- addF(pY, pY, ECP_B(pEC), pGFE);
-
- /* set z-coordinate =1 */
- cpGFpElementCopyPadd(pZ, elemLen, GFP_MNT_R(pGFE), elemLen);
-
- /* Y = sqrt(Y) */
- if( cpGFpSqrt(pY, pY, pGFE) ) {
- ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT;
- return 1;
- }
- else {
- gfec_SetPointAtInfinity(pPoint);
- return 0;
- }
-}
-
-static int gfec_IsAffinePointAtInfinity(int ecInfinity,
- const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY,
- const IppsGFpState* pGF)
-{
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elmLen = GFP_FELEN(pGFE);
-
- int atInfinity = GFP_IS_ZERO(pX,elmLen);
-
- BNU_CHUNK_T* tmpY = cpGFpGetPool(1, pGFE);
-
- /* set tmpY either:
- // 0, if ec.b !=0
- // mont(1) if ec.b ==0
- */
- cpGFpElementPadd(tmpY, elmLen, 0);
- if(ecInfinity) {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
- int basicElmLen = GFP_FELEN(pBasicGFE);
- BNU_CHUNK_T* mont1 = GFP_MNT_R(pBasicGFE);
- cpGFpElementCopyPadd(tmpY, elmLen, mont1, basicElmLen);
- }
-
- /* check if (x,y) represents point at infinity */
- atInfinity &= GFP_EQ(pY, tmpY, elmLen);
-
- cpGFpReleasePool(1, pGFE);
- return atInfinity;
-}
-
-/* returns: 1/0 if set up finite/infinite point */
-int gfec_SetPoint(BNU_CHUNK_T* pPointData,
- const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY,
- IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elmLen = GFP_FELEN(pGFE);
-
- int finite_point= !gfec_IsAffinePointAtInfinity(ECP_INFINITY(pEC), pX, pY, pGF);
- if(finite_point) {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFE);
- cpGFpElementCopy(pPointData, pX, elmLen);
- cpGFpElementCopy(pPointData+elmLen, pY, elmLen);
- cpGFpElementCopyPadd(pPointData+elmLen*2, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
- }
- else
- cpGFpElementPadd(pPointData, 3*elmLen, 0);
-
- return finite_point;
-}
-
-
-#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
-/* returns 1/0 if point is finite/infinite */
-int gfec_GetPoint(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, const IppsGFpECPoint* pPoint, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- if( !IS_ECP_FINITE_POINT(pPoint) ) {
- if(pX) cpGFpElementPadd(pX, elemLen, 0);
- if(pY) cpGFpElementPadd(pY, elemLen, 0);
- return 0;
- }
-
- /* affine point (1==Z) */
- if( IS_ECP_AFFINE_POINT(pPoint) ) {
- if(pX)
- cpGFpElementCopy(pX, ECP_POINT_X(pPoint), elemLen);
- if(pY)
- cpGFpElementCopy(pY, ECP_POINT_Y(pPoint), elemLen);
- return 1;
- }
-
- /* projective point (1!=Z) */
- {
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
-
- /* T = (1/Z)*(1/Z) */
- BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pZinv = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pU = cpGFpGetPool(1, pGFE);
- cpGFpxInv(pZinv, ECP_POINT_Z(pPoint), pGFE);
- sqrF(pT, pZinv, pGFE);
-
- if(pX) {
- mulF(pU, ECP_POINT_X(pPoint), pT, pGFE);
- cpGFpElementCopy(pX, pU, elemLen);
- }
- if(pY) {
- mulF(pT, pZinv, pT, pGFE);
- mulF(pU, ECP_POINT_Y(pPoint), pT, pGFE);
- cpGFpElementCopy(pY, pU, elemLen);
- }
-
- cpGFpReleasePool(3, pGFE);
- return 1;
- }
-}
-#endif
-
-
-#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
-int gfec_ComparePoint(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- /* P or/and Q at Infinity */
- if( !IS_ECP_FINITE_POINT(pP) )
- return !IS_ECP_FINITE_POINT(pQ)? 1:0;
- if( !IS_ECP_FINITE_POINT(pQ) )
- return !IS_ECP_FINITE_POINT(pP)? 1:0;
-
- /* Px==Qx && Py==Qy && Pz==Qz */
- if( GFP_EQ(ECP_POINT_Z(pP), ECP_POINT_Z(pQ), elemLen)
- &&GFP_EQ(ECP_POINT_X(pP), ECP_POINT_X(pQ), elemLen)
- &&GFP_EQ(ECP_POINT_Y(pP), ECP_POINT_Y(pQ), elemLen))
- return 1;
-
- else {
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
-
- int isEqu = 1;
-
- BNU_CHUNK_T* pPtmp = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pQtmp = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pPz = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pQz = cpGFpGetPool(1, pGFE);
-
- if(isEqu) {
- /* Px*Qz^2 ~ Qx*Pz^2 */
- if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Px * Qz^2 */
- cpGFpElementCopy(pPtmp, ECP_POINT_X(pP), elemLen);
- else {
- sqrF(pQz, ECP_POINT_Z(pQ), pGFE);
- mulF(pPtmp, ECP_POINT_X(pP), pQz, pGFE);
- }
- if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qx * Pz^2 */
- cpGFpElementCopy(pQtmp, ECP_POINT_X(pQ), elemLen);
- else {
- sqrF(pPz, ECP_POINT_Z(pP), pGFE);
- mulF(pQtmp, ECP_POINT_X(pQ), pPz, pGFE);
- }
- isEqu = GFP_EQ(pPtmp, pQtmp, elemLen);
- }
-
- if(isEqu) {
- /* Py*Qz^3 ~ Qy*Pz^3 */
- if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Py * Qz^3 */
- cpGFpElementCopy(pPtmp, ECP_POINT_Y(pP), elemLen);
- else {
- mulF(pQz, ECP_POINT_Z(pQ), pQz, pGFE);
- mulF(pPtmp, pQz, ECP_POINT_Y(pP), pGFE);
- }
- if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qy * Pz^3 */
- cpGFpElementCopy(pQtmp, ECP_POINT_Y(pQ), elemLen);
- else {
- mulF(pPz, ECP_POINT_Z(pP), pPz, pGFE);
- mulF(pQtmp, pPz, ECP_POINT_Y(pQ), pGFE);
- }
- isEqu = GFP_EQ(pPtmp, pQtmp, elemLen);
- }
-
- cpGFpReleasePool(4, pGFE);
- return isEqu;
- }
-}
-#endif
-
-
-#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
-int gfec_IsPointOnCurve(const IppsGFpECPoint* pPoint, IppsGFpECState* pEC)
-{
- /* point at infinity does not belong curve */
- if( !IS_ECP_FINITE_POINT(pPoint) )
- //return 1;
- return 0;
-
- /* test that 0 == R = (Y^2) - (X^3 + A*X*(Z^4) + B*(Z^6)) */
- else {
- int isOnCurve = 0;
-
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
-
- mod_mul mulF = GFP_METHOD(pGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGFE)->sqr;
- mod_sub subF = GFP_METHOD(pGFE)->sub;
-
- BNU_CHUNK_T* pX = ECP_POINT_X(pPoint);
- BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint);
- BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint);
-
- BNU_CHUNK_T* pR = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFE);
-
- sqrF(pR, pY, pGFE); /* R = Y^2 */
- sqrF(pT, pX, pGFE); /* T = X^3 */
- mulF(pT, pX, pT, pGFE);
- subF(pR, pR, pT, pGFE); /* R -= T */
-
- if( IS_ECP_AFFINE_POINT(pPoint) ) {
- mulF(pT, pX, ECP_A(pEC), pGFE); /* T = A*X */
- subF(pR, pR, pT, pGFE); /* R -= T */
- subF(pR, pR, ECP_B(pEC), pGFE); /* R -= B */
- }
- else {
- BNU_CHUNK_T* pZ4 = cpGFpGetPool(1, pGFE);
- BNU_CHUNK_T* pZ6 = cpGFpGetPool(1, pGFE);
-
- sqrF(pZ6, pZ, pGFE); /* Z^2 */
- sqrF(pZ4, pZ6, pGFE); /* Z^4 */
- mulF(pZ6, pZ6, pZ4, pGFE); /* Z^6 */
-
- mulF(pZ4, pZ4, pX, pGFE); /* X*(Z^4) */
- mulF(pZ4, pZ4, ECP_A(pEC), pGFE); /* A*X*(Z^4) */
- mulF(pZ6, pZ6, ECP_B(pEC), pGFE); /* B*(Z^4) */
-
- subF(pR, pR, pZ4, pGFE); /* R -= A*X*(Z^4) */
- subF(pR, pR, pZ6, pGFE); /* R -= B*(Z^6) */
-
- cpGFpReleasePool(2, pGFE);
- }
-
- isOnCurve = GFP_IS_ZERO(pR, GFP_FELEN(pGFE));
- cpGFpReleasePool(2, pGFE);
- return isOnCurve;
- }
-}
-#endif
-
-IppsGFpECPoint* gfec_NegPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elmLen = GFP_FELEN(pGFE);
- if(pR!=pP)
- gfec_CopyPoint(pR, pP, elmLen);
- GFP_METHOD(pGFE)->neg(ECP_POINT_Y(pR), ECP_POINT_Y(pP), pGFE);
- return pR;
-}
-
-
-#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
-/*
-// A = 4*x*y^2
-// B = 3*x^2 + a*z^4
-//
-// x3 = -2*A + B^2
-// y3 = -8y^4 +B*(A-x3)
-// z3 = 2*y*z
-//
-// complexity: = 4s+4m (NIST's, SM2 curves)
-// = (EPID2 curve)
-// = 6s+4m (arbitrary curves)
-*/
-static void gfec_point_double(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_add add = GFP_METHOD(pGFE)->add; /* gf add */
- mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
- mod_div2 div2= GFP_METHOD(pGFE)->div2; /* gf div2 */
- mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
- mod_mul3 mul3= GFP_METHOD(pGFE)->mul3; /* gf mul3 */
- mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
- mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
-
- const BNU_CHUNK_T* pX = pPdata;
- const BNU_CHUNK_T* pY = pPdata+elemLen;
- const BNU_CHUNK_T* pZ = pPdata+2*+elemLen;
-
- BNU_CHUNK_T* rX = pRdata;
- BNU_CHUNK_T* rY = pRdata+elemLen;
- BNU_CHUNK_T* rZ = pRdata+2*elemLen;
-
- /* get temporary from top of EC point pool */
- BNU_CHUNK_T* U = pEC->pPool;
- BNU_CHUNK_T* M = U+elemLen;
- BNU_CHUNK_T* S = M+elemLen;
-
- mul2(S, pY, pGFE); /* S = 2*Y */
- sqr(U, pZ, pGFE); /* U = Z^2 */
-
- sqr(M, S, pGFE); /* M = 4*Y^2 */
- mul(rZ, S, pZ, pGFE); /* Zres = 2*Y*Z */
-
- sqr(rY, M, pGFE); /* Yres = 16*Y^4 */
-
- mul(S, M, pX, pGFE); /* S = 4*X*Y^2 */
- div2(rY, rY, pGFE); /* Yres = 8*Y^4 */
-
- if(ECP_STD==ECP_SPECIFIC(pEC)) {
- add(M, pX, U, pGFE); /* M = 3*(X^2-Z^4) */
- sub(U, pX, U, pGFE);
- mul(M, M, U, pGFE);
- mul3(M, M, pGFE);
- }
- else {
- sqr(M, pX, pGFE); /* M = 3*X^2 */
- mul3(M, M, pGFE);
- if(ECP_EPID2!=ECP_SPECIFIC(pEC)) {
- sqr(U, U, pGFE); /* M = 3*X^2+a*Z4 */
- mul(U, U, ECP_A(pEC), pGFE);
- add(M, M, U, pGFE);
- }
- }
-
- mul2(U, S, pGFE); /* U = 8*X*Y^2 */
- sqr(rX, M, pGFE); /* Xres = M^2 */
- sub(rX, rX, U, pGFE); /* Xres = M^2-U */
-
- sub(S, S, rX, pGFE); /* S = 4*X*Y^2-Xres */
- mul(S, S, M, pGFE); /* S = M*(4*X*Y^2-Xres) */
- sub(rY, S, rY, pGFE); /* Yres = M*(4*X*Y^2-Xres) -8*Y^4 */
-}
-#endif
-
-IppsGFpECPoint* gfec_DblPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, IppsGFpECState* pEC)
-{
- gfec_point_double(ECP_POINT_X(pR), ECP_POINT_X(pP), pEC);
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
-}
-
-
-#if ( ECP_PROJECTIVE_COORD == JACOBIAN )
-/*
-// S1 = y1*z2^3
-// S2 = y2*z1^3
-//
-// U1 = x1*z2^2
-// U2 = x2*z1^2
-
-// R = S2-S1
-// H = U2-U1
-//
-// x3 = -H^3 -2*U1*H^2 +R2
-// y3 = -S1*H^3 +R*(U1*H^2 -x3)
-// z3 = z1*z2*H
-//
-// complexity = 4s+12m
-*/
-static void gfec_point_add(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, const BNU_CHUNK_T* pQdata, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
- mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
- mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
- mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
-
- /* coordinates of P */
- const BNU_CHUNK_T* px1 = pPdata;
- const BNU_CHUNK_T* py1 = pPdata+elemLen;
- const BNU_CHUNK_T* pz1 = pPdata+2*elemLen;
-
- /* coordinates of Q */
- const BNU_CHUNK_T* px2 = pQdata;
- const BNU_CHUNK_T* py2 = pQdata+elemLen;
- const BNU_CHUNK_T* pz2 = pQdata+2*elemLen;
-
- int inftyP = GFP_IS_ZERO(pz1, elemLen);
- int inftyQ = GFP_IS_ZERO(pz2, elemLen);
-
- /* get temporary from top of EC point pool */
- BNU_CHUNK_T* U1 = pEC->pPool;
- BNU_CHUNK_T* U2 = U1 + elemLen;
- BNU_CHUNK_T* S1 = U2 + elemLen;
- BNU_CHUNK_T* S2 = S1 + elemLen;
- BNU_CHUNK_T* H = S2 + elemLen;
- BNU_CHUNK_T* R = H + elemLen;
-
- BNU_CHUNK_T* pRx = R + elemLen; /* temporary result */
- BNU_CHUNK_T* pRy = pRx+ elemLen;
- BNU_CHUNK_T* pRz = pRy+ elemLen;
-
- mul(S1, py1, pz2, pGFE); // S1 = Y1*Z2
- sqr(U1, pz2, pGFE); // U1 = Z2^2
-
- mul(S2, py2, pz1, pGFE); // S2 = Y2*Z1
- sqr(U2, pz1, pGFE); // U2 = Z1^2
-
- mul(S1, S1, U1, pGFE); // S1 = Y1*Z2^3
- mul(S2, S2, U2, pGFE); // S2 = Y2*Z1^3
-
- mul(U1, px1, U1, pGFE); // U1 = X1*Z2^2
- mul(U2, px2, U2, pGFE); // U2 = X2*Z1^2
-
- sub(R, S2, S1, pGFE); // R = S2-S1
- sub(H, U2, U1, pGFE); // H = U2-U1
-
- if( GFP_IS_ZERO(H, elemLen) && !inftyP && !inftyQ ) {
- if( GFP_IS_ZERO(R, elemLen) )
- gfec_point_double(pRdata, pPdata, pEC);
- else
- cpGFpElementPadd(pRdata, 3*elemLen, 0);
- return;
- }
-
- mul(pRz, pz1, pz2, pGFE); // Z3 = Z1*Z2
- sqr(U2, H, pGFE); // U2 = H^2
- mul(pRz, pRz, H, pGFE); // Z3 = (Z1*Z2)*H
- sqr(S2, R, pGFE); // S2 = R^2
- mul(H, H, U2, pGFE); // H = H^3
-
- mul(U1, U1, U2, pGFE); // U1 = U1*H^2
- sub(pRx, S2, H, pGFE); // X3 = R^2 - H^3
- mul2(U2, U1, pGFE); // U2 = 2*U1*H^2
- mul(S1, S1, H, pGFE); // S1 = S1*H^3
- sub(pRx, pRx, U2, pGFE); // X3 = (R^2 - H^3) -2*U1*H^2
-
- sub(pRy, U1, pRx, pGFE); // Y3 = R*(U1*H^2 - X3) -S1*H^3
- mul(pRy, pRy, R, pGFE);
- sub(pRy, pRy, S1, pGFE);
-
- cpMaskMove(pRx, px2, elemLen*3, inftyP);
- cpMaskMove(pRx, px1, elemLen*3, inftyQ);
-
- cpGFpElementCopy(pRdata, pRx, 3*elemLen);
-}
-
-/*
-// complexity = 3s+8m
-*/
-static void gfec_affine_point_add(BNU_CHUNK_T* pRdata, const BNU_CHUNK_T* pPdata, const BNU_CHUNK_T* pAdata, IppsGFpECState* pEC)
-{
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_sub sub = GFP_METHOD(pGFE)->sub; /* gf sub */
- mod_mul2 mul2= GFP_METHOD(pGFE)->mul2; /* gf mul2 */
- mod_mul mul = GFP_METHOD(pGFE)->mul; /* gf mul */
- mod_sqr sqr = GFP_METHOD(pGFE)->sqr; /* gf sqr */
-
- BNU_CHUNK_T* mont1 = GFP_MNT_R(pGFE);
-
- /* coordinates of projective P point */
- const BNU_CHUNK_T* px = pPdata; /* x1 */
- const BNU_CHUNK_T* py = pPdata+elemLen; /* y1 */
- const BNU_CHUNK_T* pz = pPdata+2*elemLen; /* z1 */
-
- /* coordinates of affine A point, az==mont(1) */
- const BNU_CHUNK_T* ax = pAdata; /* x2 */
- const BNU_CHUNK_T* ay = pAdata+elemLen; /* y2 */
-
- int inftyP = GFP_IS_ZERO(px, elemLen) && GFP_IS_ZERO(py, elemLen);
- int inftyA = GFP_IS_ZERO(ax, elemLen) && GFP_IS_ZERO(ay, elemLen);
-
- /* get temporary from top of EC point pool */
- BNU_CHUNK_T* U2 = pEC->pPool;
- BNU_CHUNK_T* S2 = U2 + elemLen;
- BNU_CHUNK_T* H = S2 + elemLen;
- BNU_CHUNK_T* R = H + elemLen;
-
- BNU_CHUNK_T* pRx = R + elemLen; /* temporary result */
- BNU_CHUNK_T* pRy = pRx+ elemLen;
- BNU_CHUNK_T* pRz = pRy+ elemLen;
-
- sqr(R, pz, pGFE); // R = Z1^2
- mul(S2, ay, pz, pGFE); // S2 = Y2*Z1
- mul(U2, ax, R, pGFE); // U2 = X2*Z1^2
- mul(S2, S2, R, pGFE); // S2 = Y2*Z1^3
-
- sub(H, U2, px, pGFE); // H = U2-X1
- sub(R, S2, py, pGFE); // R = S2-Y1
-
- mul(pRz, H, pz, pGFE); // Z3 = H*Z1
-
- sqr(U2, H, pGFE); // U2 = H^2
- sqr(S2, R, pGFE); // S2 = R^2
- mul(H, H, U2, pGFE); // H = H^3
-
- mul(U2, U2, px, pGFE); // U2 = X1*H^2
-
- mul(pRy, H, py, pGFE); // T = Y1*H^3
-
- mul2(pRx, U2, pGFE); // X3 = 2*X1*H^2
- sub(pRx, S2, pRx, pGFE); // X3 = R^2 - 2*X1*H^2
- sub(pRx, pRx, H, pGFE); // X3 = R^2 - 2*X1*H^2 -H^3
-
- sub(U2, U2, pRx, pGFE); // U2 = X1*H^2 - X3
- mul(U2, U2, R, pGFE); // U2 = R*(X1*H^2 - X3)
- sub(pRy, U2, pRy, pGFE); // Y3 = -Y1*H^3 + R*(X1*H^2 - X3)
-
- cpMaskMove(pRx, ax, elemLen, inftyP);
- cpMaskMove(pRy, ay, elemLen, inftyP);
- cpMaskMove(pRz, mont1, elemLen, inftyP);
- cpMaskMove(pRz, ax, elemLen, inftyP&inftyA);
-
- cpMaskMove(pRx, px, elemLen*3, inftyA);
-
- cpGFpElementCopy(pRdata, pRx, 3*elemLen);
-}
-#endif
-
-IppsGFpECPoint* gfec_AddPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ,
- IppsGFpECState* pEC)
-{
- gfec_point_add(ECP_POINT_X(pR), ECP_POINT_X(pP), ECP_POINT_X(pQ), pEC);
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
-}
-
-
-/* sscm version */
-static void setupTable(BNU_CHUNK_T* pTbl,
- const BNU_CHUNK_T* pPdata,
- IppsGFpECState* pEC)
-{
- int pointLen = ECP_POINTLEN(pEC);
- //int pointLen32 = pointLen*sizeof(BNU_CHUNK_T)/sizeof(ipp32u);
-
- const int npoints = 3;
- BNU_CHUNK_T* A = cpEcGFpGetPool(npoints, pEC);
- BNU_CHUNK_T* B = A+pointLen;
- BNU_CHUNK_T* C = B+pointLen;
-
- // Table[0]
- // Table[0] is implicitly (0,0,0) {point at infinity}, therefore no need to store it
- // All other values are actually stored with an offset of -1
-
- // Table[1] ( =[1]p )
- //cpScatter32((Ipp32u*)pTbl, 16, 0, (Ipp32u*)pPdata, pointLen32);
- gsScramblePut(pTbl, (1-1), pPdata, pointLen, (5-1));
-
- // Table[2] ( =[2]p )
- gfec_point_double(A, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 1, (Ipp32u*)A, pointLen32);
- gsScramblePut(pTbl, (2-1), A, pointLen, (5-1));
-
- // Table[3] ( =[3]p )
- gfec_point_add(B, A, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 2, (Ipp32u*)B, pointLen32);
- gsScramblePut(pTbl, (3-1), B, pointLen, (5-1));
-
- // Table[4] ( =[4]p )
- gfec_point_double(A, A, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 3, (Ipp32u*)A, pointLen32);
- gsScramblePut(pTbl, (4-1), A, pointLen, (5-1));
-
- // Table[5] ( =[5]p )
- gfec_point_add(C, A, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 4, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (5-1), C, pointLen, (5-1));
-
- // Table[10] ( =[10]p )
- gfec_point_double(C, C, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 9, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (10-1), C, pointLen, (5-1));
-
- // Table[11] ( =[11]p )
- gfec_point_add(C, C, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 10, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (11-1), C, pointLen, (5-1));
-
- // Table[6] ( =[6]p )
- gfec_point_double(B, B, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 5, (Ipp32u*)B, pointLen32);
- gsScramblePut(pTbl, (6-1), B, pointLen, (5-1));
-
- // Table[7] ( =[7]p )
- gfec_point_add(C, B, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 6, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (7-1), C, pointLen, (5-1));
-
- // Table[14] ( =[14]p )
- gfec_point_double(C, C, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 13, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (14-1), C, pointLen, (5-1));
-
- // Table[15] ( =[15]p )
- gfec_point_add(C, C, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 14, (Ipp32u*)C, pointLen32);
- gsScramblePut(pTbl, (15-1), C, pointLen, (5-1));
-
- // Table[12] ( =[12]p )
- gfec_point_double(B, B, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 11, (Ipp32u*)B, pointLen32);
- gsScramblePut(pTbl, (12-1), B, pointLen, (5-1));
-
- // Table[13] ( =[13]p )
- gfec_point_add(B, B, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 12, (Ipp32u*)B, pointLen32);
- gsScramblePut(pTbl, (13-1), B, pointLen, (5-1));
-
- // Table[8] ( =[8]p )
- gfec_point_double(A, A, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 7, (Ipp32u*)A, pointLen32);
- gsScramblePut(pTbl, (8-1), A, pointLen, (5-1));
-
- // Table[9] ( =[9]p )
- gfec_point_add(B, A, pPdata, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 8, (Ipp32u*)B, pointLen32);
- gsScramblePut(pTbl, (9-1), B, pointLen, (5-1));
-
- // Table[16] ( =[16]p )
- gfec_point_double(A, A, pEC);
- //cpScatter32((Ipp32u*)pTbl, 16, 15, (Ipp32u*)A, pointLen32);
- gsScramblePut(pTbl, (16-1), A, pointLen, (5-1));
-
- cpEcGFpReleasePool(npoints, pEC);
-}
-
-
-static void gfec_point_mul(BNU_CHUNK_T* pRdata,
- const BNU_CHUNK_T* pPdata,
- const Ipp8u* pScalar8, int scalarBitSize,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- int pointLen = ECP_POINTLEN(pEC);
- //int pointLen32 = pointLen*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
-
- /* optimal size of window */
- const int window_size = 5;
- /* number of table entries */
- //const int tableLen = 1<<(window_size-1);
-
- /* aligned pre-computed table */
- BNU_CHUNK_T* pTable = (BNU_CHUNK_T*)IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE);
-
- if (!pScratchBuffer)
- return;
-
- setupTable(pTable, pPdata, pEC);
-
- {
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_neg negF = GFP_METHOD(pGFE)->neg;
-
- BNU_CHUNK_T* pHy = cpGFpGetPool(1, pGFE);
-
- BNU_CHUNK_T* pTdata = cpEcGFpGetPool(1, pEC); /* points from the pool */
- BNU_CHUNK_T* pHdata = cpEcGFpGetPool(1, pEC);
-
- int wvalue;
- Ipp8u digit, sign;
- int mask = (1<<(window_size+1)) -1;
- int bit = scalarBitSize-(scalarBitSize%window_size);
-
- /* first window */
- if(bit) {
- wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- }
- else
- wvalue = 0;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pTdata, pointLen32, (Ipp32u*)pTable, tableLen, digit);
- gsScrambleGet_sscm(pTdata, pointLen, pTable, digit-1, 5-1);
-
- for(bit-=window_size; bit>=window_size; bit-=window_size) {
- gfec_point_double(pTdata, pTdata, pEC); //it's better to have separate calls
- gfec_point_double(pTdata, pTdata, pEC); // instead of gfec_point_double_k()
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
-
- wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTable, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTable, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
- }
-
- /* last window */
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
-
- wvalue = *((Ipp16u*)&pScalar8[0]);
- wvalue = (wvalue << 1) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTable, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTable, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
-
- cpGFpElementCopy(pRdata, pTdata, pointLen);
-
- cpEcGFpReleasePool(2, pEC);
- cpGFpReleasePool(1, pGFE);
- }
-}
-
-static void gfec_base_point_mul(BNU_CHUNK_T* pRdata, const Ipp8u* pScalar8, int scalarBitSize, IppsGFpECState* pEC)
-{
- /* size of window, get function and pre-computed table */
- int window_size = ECP_PREMULBP(pEC)->w;
- selectAP select_affine_point = ECP_PREMULBP(pEC)->select_affine_point;
- const BNU_CHUNK_T* pTbl = ECP_PREMULBP(pEC)->pTbl;
-
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elmLen = GFP_FELEN(pGFE);
-
- mod_neg negF = GFP_METHOD(pGFE)->neg;
-
- BNU_CHUNK_T* mont1 = GFP_MNT_R(pGFE);
-
- /* number of points per table slot */
- int tslot_point = 1<<(window_size-1);
- int tslot_size = tslot_point * (elmLen*2);
-
- BNU_CHUNK_T* negtmp = cpGFpGetPool(1, pGFE); /* temporary element */
- BNU_CHUNK_T* pointT = cpEcGFpGetPool(1, pEC); /* temporary point */
-
- Ipp8u digit, sign;
- int mask = (1<<(window_size+1)) -1;
- int bit = 0;
-
- /* processing of window[0] */
- int wvalue = *((Ipp16u*)&pScalar8[0]);
- wvalue = (wvalue << 1) & mask;
-
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- select_affine_point(pRdata, pTbl, digit);
-
- negF(negtmp, pRdata+elmLen, pGFE);
- cpMaskMove(pRdata+elmLen, negtmp, elmLen, sign);
- cpGFpElementCopy(pRdata+elmLen*2, mont1, elmLen);
- cpGFpElementCopy(pointT+elmLen*2, mont1, elmLen);
-
- /* processing of other windows.. [1],[2],... */
- for(bit+=window_size, pTbl+=tslot_size; bit<=scalarBitSize; bit+=window_size, pTbl+=tslot_size) {
- wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
-
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- select_affine_point(pointT, pTbl, digit);
-
- negF(negtmp, pointT+elmLen, pGFE);
- cpMaskMove(pointT+elmLen, negtmp, elmLen, sign);
-
- gfec_affine_point_add(pRdata, pRdata, pointT, pEC);
- }
-
- cpEcGFpReleasePool(1, pEC);
- cpGFpReleasePool(1, pGFE);
-}
-
-static void gfec_point_prod(BNU_CHUNK_T* pointR,
- const BNU_CHUNK_T* pointA, const Ipp8u* scalarA,
- const BNU_CHUNK_T* pointB, const Ipp8u* scalarB,
- int scalarBitSize,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- int pointLen = ECP_POINTLEN(pEC);
- //int pointLen32 = pointLen*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
-
- /* optimal size of window */
- const int window_size = 5;
- /* number of table entries */
- const int tableLen = 1<<(window_size-1);
-
- /* aligned pre-computed tables */
- BNU_CHUNK_T* pTableA = (BNU_CHUNK_T*)IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE);
- BNU_CHUNK_T* pTableB = pTableA+pointLen*tableLen;
-
- if (!pScratchBuffer)
- return;
-
- setupTable(pTableA, pointA, pEC);
- setupTable(pTableB, pointB, pEC);
-
- {
- IppsGFpState* pGF = ECP_GFP(pEC);
- gsModEngine* pGFE = GFP_PMA(pGF);
- int elemLen = GFP_FELEN(pGFE);
-
- mod_neg negF = GFP_METHOD(pGFE)->neg;
-
- BNU_CHUNK_T* pHy = cpGFpGetPool(1, pGFE);
-
- BNU_CHUNK_T* pTdata = cpEcGFpGetPool(1, pEC); /* points from the pool */
- BNU_CHUNK_T* pHdata = cpEcGFpGetPool(1, pEC);
-
- int wvalue;
- Ipp8u digit, sign;
- int mask = (1<<(window_size+1)) -1;
- int bit = scalarBitSize-(scalarBitSize%window_size);
-
- /* first window */
- if(bit) {
- wvalue = *((Ipp16u*)&scalarA[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- }
- else
- wvalue = 0;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pTdata, pointLen32, (Ipp32u*)pTableA, tableLen, digit);
- gsScrambleGet_sscm(pTdata, pointLen, pTableA, digit-1, 5-1);
-
- if(bit) {
- wvalue = *((Ipp16u*)&scalarB[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- }
- else
- wvalue = 0;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTableB, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
-
- //negF(pHy, pHdata+elemLen, pGFE);
- //cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
-
- for(bit-=window_size; bit>=window_size; bit-=window_size) {
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
-
- wvalue = *((Ipp16u*)&scalarA[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTableA, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTableA, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
-
- wvalue = *((Ipp16u*)&scalarB[(bit-1)/8]);
- wvalue = (wvalue>> ((bit-1)%8)) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTableB, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
- }
- /* last window */
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
- gfec_point_double(pTdata, pTdata, pEC);
-
- wvalue = *((Ipp16u*)&scalarA[0]);
- wvalue = (wvalue << 1) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTableA, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTableA, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
-
- wvalue = *((Ipp16u*)&scalarB[0]);
- wvalue = (wvalue << 1) & mask;
- booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size);
- //cpGather32((Ipp32u*)pHdata, pointLen32, (Ipp32u*)pTableB, tableLen, digit);
- gsScrambleGet_sscm(pHdata, pointLen, pTableB, digit-1, 5-1);
-
- negF(pHy, pHdata+elemLen, pGFE);
- cpMaskMove(pHdata+elemLen, pHy, elemLen, sign);
- gfec_point_add(pTdata, pTdata, pHdata, pEC);
-
- cpGFpElementCopy(pointR, pTdata, pointLen);
-
- cpEcGFpReleasePool(2, pEC);
- cpGFpReleasePool(1, pGFE);
- }
-}
-
-/*
-// select affine point
-*/
-#if (_IPP32E < _IPP32E_M7)
-void p192r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
-{
- #define OPERAND_BITSIZE (192)
- #define LEN_P192 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
- #define LEN_P192_APOINT (2*LEN_P192)
-
- const int tblLen = 64;
- int i;
- unsigned int n;
-
- /* clear output affine point */
- for(n=0; n<LEN_P192_APOINT; n++)
- pVal[n] = 0;
-
- /* select poiint */
- for(i=1; i<=tblLen; i++) {
- BNU_CHUNK_T mask = 0 - isZero(i-idx);
- for(n=0; n<LEN_P192_APOINT; n++)
- pVal[n] |= (pTbl[n] & mask);
- pTbl += LEN_P192_APOINT;
- }
-
- #undef OPERAND_BITSIZE
- #undef LEN_P192
- #undef LEN_P192_APOINT
-}
-
-void p224r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
-{
- #define OPERAND_BITSIZE (224)
- #define LEN_P224 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
- #define LEN_P224_APOINT (2*LEN_P224)
-
- const int tblLen = 64;
- int i;
- unsigned int n;
-
- /* clear output affine point */
- for(n=0; n<LEN_P224_APOINT; n++)
- pVal[n] = 0;
-
- /* select poiint */
- for(i=1; i<=tblLen; i++) {
- BNU_CHUNK_T mask = 0 - isZero(i-idx);
- for(n=0; n<LEN_P224_APOINT; n++)
- pVal[n] |= (pTbl[n] & mask);
- pTbl += LEN_P224_APOINT;
- }
-
- #undef OPERAND_BITSIZE
- #undef LEN_P224
- #undef LEN_P224_APOINT
-}
-
-void p256r1_select_ap_w7(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
-{
- #define OPERAND_BITSIZE (256)
- #define LEN_P256 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
- #define LEN_P256_APOINT (2*LEN_P256)
-
- const int tblLen = 64;
- int i;
- unsigned int n;
-
- /* clear output affine point */
- for(n=0; n<LEN_P256_APOINT; n++)
- pVal[n] = 0;
-
- /* select poiint */
- for(i=1; i<=tblLen; i++) {
- BNU_CHUNK_T mask = 0 - isZero(i-idx);
- for(n=0; n<LEN_P256_APOINT; n++)
- pVal[n] |= (pTbl[n] & mask);
- pTbl += LEN_P256_APOINT;
- }
-
- #undef OPERAND_BITSIZE
- #undef LEN_P256
- #undef LEN_P256_APOINT
-}
-
-void p384r1_select_ap_w5(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
-{
- #define OPERAND_BITSIZE (384)
- #define LEN_P384 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
- #define LEN_P384_APOINT (2*LEN_P384)
-
- const int tblLen = 16;
- int i;
- unsigned int n;
-
- /* clear output affine point */
- for(n=0; n<LEN_P384_APOINT; n++)
- pVal[n] = 0;
-
- /* select poiint */
- for(i=1; i<=tblLen; i++) {
- BNU_CHUNK_T mask = 0 - isZero(i-idx);
- for(n=0; n<LEN_P384_APOINT; n++)
- pVal[n] |= (pTbl[n] & mask);
- pTbl += LEN_P384_APOINT;
- }
-
- #undef OPERAND_BITSIZE
- #undef LEN_P384
- #undef LEN_P384_APOINT
-}
-
-void p521r1_select_ap_w5(BNU_CHUNK_T* pVal, const BNU_CHUNK_T* pTbl, int idx)
-{
- #define OPERAND_BITSIZE (521)
- #define LEN_P521 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
- #define LEN_P521_APOINT (2*LEN_P521)
-
- const int tblLen = 16;
- int i;
- unsigned int n;
-
- /* clear output affine point */
- for(n=0; n<LEN_P521_APOINT; n++)
- pVal[n] = 0;
-
- /* select point */
- for(i=1; i<=tblLen; i++) {
- BNU_CHUNK_T mask = 0 - isZero(i-idx);
- for(n=0; n<LEN_P521_APOINT; n++)
- pVal[n] |= (pTbl[n] & mask);
- pTbl += LEN_P521_APOINT;
- }
-
- #undef OPERAND_BITSIZE
- #undef LEN_P521
- #undef P521_POINT_AFFINE
-}
-#endif
-
-IppsGFpECPoint* gfec_MulPoint(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP,
- const BNU_CHUNK_T* pScalar, int scalarLen,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- FIX_BNU(pScalar, scalarLen);
- {
- gsModEngine* pGForder = ECP_MONT_R(pEC);
-
- BNU_CHUNK_T* pTmpScalar = cpGFpGetPool(1, pGForder); /* length of scalar does not exceed length of order */
- int orderBits = MOD_BITSIZE(pGForder);
- int orderLen = MOD_LEN(pGForder);
- cpGFpElementCopyPadd(pTmpScalar,orderLen+1, pScalar,scalarLen);
-
- gfec_point_mul(ECP_POINT_X(pR), ECP_POINT_X(pP),
- (Ipp8u*)pTmpScalar, orderBits,
- pEC, pScratchBuffer);
- cpGFpReleasePool(1, pGForder);
-
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
- }
-}
-
-IppsGFpECPoint* gfec_MulBasePoint(IppsGFpECPoint* pR,
- const BNU_CHUNK_T* pScalar, int scalarLen,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- FIX_BNU(pScalar, scalarLen);
- {
- gsModEngine* pGForder = ECP_MONT_R(pEC);
-
- BNU_CHUNK_T* pTmpScalar = cpGFpGetPool(1, pGForder); /* length of scalar does not exceed length of order */
- int orderBits = MOD_BITSIZE(pGForder);
- int orderLen = MOD_LEN(pGForder);
- cpGFpElementCopyPadd(pTmpScalar,orderLen+1, pScalar,scalarLen);
-
- if(ECP_PREMULBP(pEC))
- gfec_base_point_mul(ECP_POINT_X(pR),
- (Ipp8u*)pTmpScalar, orderBits,
- pEC);
- else
- gfec_point_mul(ECP_POINT_X(pR), ECP_G(pEC),
- (Ipp8u*)pTmpScalar, orderBits,
- pEC, pScratchBuffer);
- cpGFpReleasePool(1, pGForder);
-
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
- }
-}
-
-IppsGFpECPoint* gfec_PointProduct(IppsGFpECPoint* pR,
- const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalarP, int scalarPlen,
- const IppsGFpECPoint* pQ, const BNU_CHUNK_T* pScalarQ, int scalarQlen,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- FIX_BNU(pScalarP, scalarPlen);
- FIX_BNU(pScalarQ, scalarQlen);
- {
- gsModEngine* pGForder = ECP_MONT_R(pEC);
-
- int orderBits = MOD_BITSIZE(pGForder);
- int orderLen = MOD_LEN(pGForder);
- BNU_CHUNK_T* tmpScalarP = cpGFpGetPool(2, pGForder);
- BNU_CHUNK_T* tmpScalarQ = tmpScalarP+orderLen+1;
- cpGFpElementCopyPadd(tmpScalarP, orderLen+1, pScalarP,scalarPlen);
- cpGFpElementCopyPadd(tmpScalarQ, orderLen+1, pScalarQ,scalarQlen);
-
- gfec_point_prod(ECP_POINT_X(pR),
- ECP_POINT_X(pP), (Ipp8u*)tmpScalarP,
- ECP_POINT_X(pQ), (Ipp8u*)tmpScalarQ,
- orderBits,
- pEC, pScratchBuffer);
- cpGFpReleasePool(2, pGForder);
-
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
- }
-}
-
-IppsGFpECPoint* gfec_BasePointProduct(IppsGFpECPoint* pR,
- const BNU_CHUNK_T* pScalarG, int scalarGlen,
- const IppsGFpECPoint* pP, const BNU_CHUNK_T* pScalarP, int scalarPlen,
- IppsGFpECState* pEC, Ipp8u* pScratchBuffer)
-{
- FIX_BNU(pScalarG, scalarGlen);
- FIX_BNU(pScalarP, scalarPlen);
-
- {
- gsModEngine* pGForder = ECP_MONT_R(pEC);
- int orderBits = MOD_BITSIZE(pGForder);
- int orderLen = MOD_LEN(pGForder);
- BNU_CHUNK_T* tmpScalarG = cpGFpGetPool(2, pGForder);
- BNU_CHUNK_T* tmpScalarP = tmpScalarG+orderLen+1;
-
- cpGFpElementCopyPadd(tmpScalarG, orderLen+1, pScalarG,scalarGlen);
- cpGFpElementCopyPadd(tmpScalarP, orderLen+1, pScalarP,scalarPlen);
-
- if(ECP_PREMULBP(pEC)) {
- BNU_CHUNK_T* productG = cpEcGFpGetPool(2, pEC);
- BNU_CHUNK_T* productP = productG+ECP_POINTLEN(pEC);
-
- gfec_base_point_mul(productG, (Ipp8u*)tmpScalarG, orderBits, pEC);
- gfec_point_mul(productP, ECP_POINT_X(pP), (Ipp8u*)tmpScalarP, orderBits, pEC, pScratchBuffer);
- gfec_point_add(ECP_POINT_X(pR), productG, productP, pEC);
-
- cpEcGFpReleasePool(2, pEC);
- }
-
- else {
- gfec_point_prod(ECP_POINT_X(pR),
- ECP_G(pEC), (Ipp8u*)tmpScalarG,
- ECP_POINT_X(pP), (Ipp8u*)tmpScalarP,
- orderBits,
- pEC, pScratchBuffer);
- }
-
- cpGFpReleasePool(2, pGForder);
- }
-
- ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR)? 0 : ECP_FINITE_POINT;
- return pR;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecsigndsa.c b/ext/ipp/sources/ippcp/src/pcpgfpecsigndsa.c
deleted file mode 100644
index 051fd85..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecsigndsa.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// DSA signature generation and verification
-//
-// Contents:
-// ippsGFpECSignDSA()
-// ippsGFpECVerifyDSA()
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsGFpECSignDSA
-//
-// Purpose: DSA Signature Generation.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPrivate
-// NULL == pEphPrivate
-// NULL == pSignC
-// NULL == pSignD
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pMsg->idCtx
-// illegal pRegPrivate->idCtx
-// illegal pEphPrivate->idCtx
-// illegal pSignC->idCtx
-// illegal pSignD->idCtx
-//
-// ippStsMessageErr Msg < 0
-//
-// ippStsRangeErr not enough room for:
-// signC
-// signD
-//
-// ippStsErr (0==signC) || (0==signD)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to be signed
-// pRegPrivate pointer to the regular private key
-// pEphPrivate pointer to the ephemeral private key
-// pSignR,pSignS pointer to the signature
-// pEC pointer to the EC context
-// pScratchBuffer pointer to buffer (1 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECSignDSA,(const IppsBigNumState* pMsg,
- const IppsBigNumState* pRegPrivate,
- const IppsBigNumState* pEphPrivate,
- IppsBigNumState* pSignC, IppsBigNumState* pSignD,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pMsg), ippStsMessageErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignC, pSignD);
- pSignC = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignC, BN_ALIGNMENT) );
- pSignD = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignD, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignC), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignD), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pSignC)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
- IPP_BADARG_RET((BN_ROOM(pSignD)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- /* test private keys */
- IPP_BAD_PTR2_RET(pRegPrivate, pEphPrivate);
- pRegPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRegPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pRegPrivate), ippStsContextMatchErr);
- pEphPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pEphPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pEphPrivate), ippStsContextMatchErr);
-
- {
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- BNU_CHUNK_T* dataC = BN_NUMBER(pSignC);
- BNU_CHUNK_T* dataD = BN_NUMBER(pSignD);
- BNU_CHUNK_T* buffD = BN_BUFFER(pSignD);
- BNU_CHUNK_T* buffMsg = BN_BUFFER(pMsg);
-
- /* test value of private keys: regPrivate<order, ephPrivate<order */
- IPP_BADARG_RET(BN_NEGATIVE(pRegPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pRegPrivate), BN_SIZE(pRegPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
- IPP_BADARG_RET(BN_NEGATIVE(pEphPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
- {
- int elmLen = GFP_FELEN(pGFE);
- int ns;
-
- /* compute ephemeral public key */
- IppsGFpECPoint ephPublic;
- cpEcGFpInitPoint(&ephPublic, cpEcGFpGetPool(1, pEC), 0, pEC);
- gfec_MulBasePoint(&ephPublic,
- BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate),
- pEC, pScratchBuffer);
-
- /* C = (ephPublic.x) mod order */
- gfec_GetPoint(dataC, NULL, &ephPublic, pEC);
- GFP_METHOD(pGFE)->decode(dataC, dataC, pGFE);
- ns = cpMod_BNU(dataC, elmLen, pOrder, orderLen);
- cpGFpElementPadd(dataC+ns, orderLen-ns, 0);
-
- cpEcGFpReleasePool(1, pEC);
-
- /* check c!=0 */
- if(GFP_IS_ZERO(dataC, orderLen)) return ippStsErr;
-
- /* reduce message: msg = msg mod ordfer */
- COPY_BNU(buffMsg, BN_NUMBER(pMsg), BN_SIZE(pMsg));
- ns = cpMod_BNU(buffMsg, BN_SIZE(pMsg), pOrder, orderLen);
- ZEXPAND_BNU(buffMsg+ns, orderLen-ns, 0);
-
- /* D = (ephPrivate^-1) * (msg + regPrivate*C) mod order */
- ZEXPAND_COPY_BNU(buffD, orderLen, BN_NUMBER(pRegPrivate),BN_SIZE(pRegPrivate));
- cpMontEnc_BNU_EX(buffD, buffD, orderLen, pMontR);
- cpMontMul_BNU(buffD, buffD, dataC, pMontR);
- cpModAdd_BNU(buffD, buffD, buffMsg, pOrder, orderLen, dataD);
-
- ZEXPAND_COPY_BNU(dataD, orderLen, BN_NUMBER(pEphPrivate),BN_SIZE(pEphPrivate));
-
- //cpMontInv_BNU(dataD, dataD, pMontR); /* d = ephPrivate^-1 */
- gs_mont_inv(dataD, dataD, pMontR); /* d = ephPrivate^-1 */
- cpMontMul_BNU(dataD, dataD, buffD, pMontR);
-
- /* check d!=0 */
- if(GFP_IS_ZERO(dataD, orderLen)) return ippStsErr;
-
- /* signC */
- ns = orderLen;
- FIX_BNU(dataC, ns);
- BN_SIGN(pSignC) = ippBigNumPOS;
- BN_SIZE(pSignC) = ns;
- /* signD */
- ns = orderLen;
- FIX_BNU(dataD, ns);
- BN_SIGN(pSignD) = ippBigNumPOS;
- BN_SIZE(pSignD) = ns;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsGFpECVerifyDSA
-//
-// Purpose: DSA Signature Verification.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPublic
-// NULL == pSignC
-// NULL == pSignD
-// NULL == pResult
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pMsgDigest->idCtx
-// illegal pRegPublic->idCtx
-// illegal pSignC->idCtx
-// illegal pSignD->idCtx
-//
-// ippStsMessageErr Msg < 0
-// ippStsRangeErr SignC < 0 or SignD < 0
-//
-// ippStsOutOfRangeErr bitsize(pRegPublic) != bitsize(prime)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to being signed
-// pRegPublic pointer to the regular public key
-// pSignC,pSignD pointer to the signature
-// pResult pointer to the result: ippECValid/ippECInvalidSignature
-// pEC pointer to the ECCP context
-// pScratchBuffer pointer to buffer (2 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECVerifyDSA,(const IppsBigNumState* pMsg,
- const IppsGFpECPoint* pRegPublic,
- const IppsBigNumState* pSignC, const IppsBigNumState* pSignD,
- IppECResult* pResult,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pMsg), ippStsMessageErr);
-
- /* test regular public key */
- IPP_BAD_PTR1_RET(pRegPublic);
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
- IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignC, pSignD);
- pSignC = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignC, ALIGN_VAL) );
- pSignD = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignD, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignC), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignD), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignC), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignD), ippStsRangeErr);
-
- /* test result */
- IPP_BAD_PTR1_RET(pResult);
-
- {
- IppECResult vResult = ippECInvalidSignature;
-
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- /* test signature value */
- if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignC), BN_SIZE(pSignC), 0) &&
- !cpEqu_BNU_CHUNK(BN_NUMBER(pSignD), BN_SIZE(pSignD), 0) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignC), BN_SIZE(pSignC), pOrder, orderLen) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignD), BN_SIZE(pSignD), pOrder, orderLen)) {
-
- int elmLen = GFP_FELEN(pGFE);
- int pelmLen = GFP_PELEN(pGFE);
- int ns;
- BNU_CHUNK_T* h1 = cpGFpGetPool(3, pGFE);
- BNU_CHUNK_T* h2 = h1+pelmLen;
- BNU_CHUNK_T* h = h2+pelmLen;
-
- BNU_CHUNK_T* buffMsg = BN_BUFFER(pMsg);
-
- IppsGFpECPoint P;
- cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
-
- /* reduce message: h1 = msg mod ordfer */
- COPY_BNU(buffMsg, BN_NUMBER(pMsg), BN_SIZE(pMsg));
- ns = cpMod_BNU(buffMsg, BN_SIZE(pMsg), pOrder, orderLen);
- ZEXPAND_COPY_BNU(h1, orderLen, buffMsg, ns);
-
- /* h = d^-1, h1 = msg*h, h2 = c*h */
- ZEXPAND_COPY_BNU(h, orderLen, BN_NUMBER(pSignD),BN_SIZE(pSignD));
- //cpMontInv_BNU(h, h, pMontR);
- gs_mont_inv(h, h, pMontR);
-
- cpMontMul_BNU(h1, h, h1, pMontR);
- ZEXPAND_COPY_BNU(h2, orderLen, BN_NUMBER(pSignC),BN_SIZE(pSignC));
- cpMontMul_BNU(h2, h, h2, pMontR);
-
- /* P = [h1]BasePoint + [h2]publicKey */
- gfec_BasePointProduct(&P,
- h1, orderLen, pRegPublic, h2, orderLen,
- pEC, pScratchBuffer);
-
- /* get P.X */
- if(gfec_GetPoint(h1, NULL, &P, pEC)) {
- /* c' = int(P.x) mod order */
- GFP_METHOD(pGFE)->decode(h1, h1, pGFE);
- elmLen = cpMod_BNU(h1, elmLen, pOrder, orderLen);
- cpGFpElementPadd(h1+elmLen, orderLen-elmLen, 0);
-
- /* and make sure c' = signC */
- cpGFpElementCopyPadd(h2, orderLen, BN_NUMBER(pSignC), BN_SIZE(pSignC));
- if(GFP_EQ(h1, h2, orderLen))
- vResult = ippECValid;
- }
-
- cpEcGFpReleasePool(1, pEC);
- cpGFpReleasePool(3, pGFE);
- }
-
- *pResult = vResult;
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecsignnr.c b/ext/ipp/sources/ippcp/src/pcpgfpecsignnr.c
deleted file mode 100644
index 7706887..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecsignnr.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// NR signature generation and verification
-//
-// Contents:
-// ippsGFpECSignNR()
-// ippsGFpECVerifyNR()
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsGFpECSignNR
-//
-// Purpose: NR Signature Generation.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPrivate
-// NULL == pEphPrivate
-// NULL == pSignC
-// NULL == pSignD
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pMsg->idCtx
-// illegal pRegPrivate->idCtx
-// illegal pEphPrivate->idCtx
-// illegal pSignC->idCtx
-// illegal pSignD->idCtx
-//
-// ippStsMessageErr Msg < 0, Msg >= order
-//
-// ippStsRangeErr not enough room for:
-// signC
-// signD
-//
-// ippStsErr (0==signC) || (0==signD)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to be signed
-// pRegPrivate pointer to the regular private key
-// pEphPrivate pointer to the ephemeral private key
-// pSignR,pSignS pointer to the signature
-// pEC pointer to the EC context
-// pScratchBuffer pointer to buffer (1 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECSignNR,(const IppsBigNumState* pMsg,
- const IppsBigNumState* pRegPrivate,
- const IppsBigNumState* pEphPrivate,
- IppsBigNumState* pSignC, IppsBigNumState* pSignD,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignC, pSignD);
- pSignC = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignC, BN_ALIGNMENT) );
- pSignD = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignD, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignC), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignD), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pSignC)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
- IPP_BADARG_RET((BN_ROOM(pSignD)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- /* test private keys */
- IPP_BAD_PTR2_RET(pRegPrivate, pEphPrivate);
- pRegPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRegPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pRegPrivate), ippStsContextMatchErr);
- pEphPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pEphPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pEphPrivate), ippStsContextMatchErr);
-
- {
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- BNU_CHUNK_T* dataC = BN_NUMBER(pSignC);
- BNU_CHUNK_T* dataD = BN_NUMBER(pSignD);
- BNU_CHUNK_T* buffD = BN_BUFFER(pSignD);
-
- /* test value of private keys: regPrivate<order, ephPrivate<order */
- IPP_BADARG_RET(BN_NEGATIVE(pRegPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pRegPrivate), BN_SIZE(pRegPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
- IPP_BADARG_RET(BN_NEGATIVE(pEphPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
- /* test mesage: 0<msg<order */
- IPP_BADARG_RET(BN_NEGATIVE(pMsg) ||
- (0<=cpCmp_BNU(BN_NUMBER(pMsg), BN_SIZE(pMsg), pOrder, orderLen)), ippStsMessageErr);
-
- {
- int elmLen = GFP_FELEN(pGFE);
- int ns;
-
- /* compute ephemeral public key */
- IppsGFpECPoint ephPublic;
- cpEcGFpInitPoint(&ephPublic, cpEcGFpGetPool(1, pEC), 0, pEC);
- gfec_MulBasePoint(&ephPublic,
- BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate),
- pEC, pScratchBuffer);
-
- /* x = (ephPublic.x) mod order */
- gfec_GetPoint(dataC, NULL, &ephPublic, pEC);
- GFP_METHOD(pGFE)->decode(dataC, dataC, pGFE);
- ns = cpMod_BNU(dataC, elmLen, pOrder, orderLen);
- cpGFpElementPadd(dataC+ns, orderLen-ns, 0);
-
- cpEcGFpReleasePool(1, pEC);
-
- /* C = (ephPublic.x + msg) mod order */
- ZEXPAND_COPY_BNU(dataD, orderLen, BN_NUMBER(pMsg), BN_SIZE(pMsg));
- cpModAdd_BNU(dataC, dataC, dataD, pOrder, orderLen, dataD);
-
- /* check c!=0 */
- if(GFP_IS_ZERO(dataC, orderLen)) return ippStsErr;
-
- /* D = (ephPrivate - regPrivate*C) mod order */
- ZEXPAND_COPY_BNU(buffD, orderLen, BN_NUMBER(pRegPrivate),BN_SIZE(pRegPrivate));
- cpMontEnc_BNU_EX(dataD, buffD, orderLen, pMontR);
- cpMontMul_BNU(buffD, dataD, dataC, pMontR);
- ZEXPAND_COPY_BNU(dataD, orderLen, BN_NUMBER(pEphPrivate),BN_SIZE(pEphPrivate));
- cpModSub_BNU(dataD, dataD, buffD, pOrder, orderLen, buffD);
-
- /* signC */
- ns = orderLen;
- FIX_BNU(dataC, ns);
- BN_SIGN(pSignC) = ippBigNumPOS;
- BN_SIZE(pSignC) = ns;
- /* signD */
- ns = orderLen;
- FIX_BNU(dataD, ns);
- BN_SIGN(pSignD) = ippBigNumPOS;
- BN_SIZE(pSignD) = ns;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsGFpECVerifyNR
-//
-// Purpose: NR Signature Verification.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPublic
-// NULL == pSignC
-// NULL == pSignD
-// NULL == pResult
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pMsgDigest->idCtx
-// illegal pRegPublic->idCtx
-// illegal pSignC->idCtx
-// illegal pSignD->idCtx
-//
-// ippStsMessageErr Msg < 0, Msg >= order
-//
-// ippStsRangeErr SignC < 0 or SignD < 0
-//
-// ippStsOutOfRangeErr bitsize(pRegPublic) != bitsize(prime)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to being signed
-// pRegPublic pointer to the regular public key
-// pSignC,pSignD pointer to the signature
-// pResult pointer to the result: ippECValid/ippECInvalidSignature
-// pEC pointer to the ECCP context
-// pScratchBuffer pointer to buffer (2 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECVerifyNR,(const IppsBigNumState* pMsg,
- const IppsGFpECPoint* pRegPublic,
- const IppsBigNumState* pSignC, const IppsBigNumState* pSignD,
- IppECResult* pResult,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
-
- /* test regular public key */
- IPP_BAD_PTR1_RET(pRegPublic);
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
- IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignC, pSignD);
- pSignC = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignC, ALIGN_VAL) );
- pSignD = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignD, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignC), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignD), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignC), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignD), ippStsRangeErr);
-
- /* test result */
- IPP_BAD_PTR1_RET(pResult);
-
- {
- IppECResult vResult = ippECInvalidSignature;
-
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- /* test mesage: 0<msg<order */
- IPP_BADARG_RET(BN_NEGATIVE(pMsg) ||
- (0<=cpCmp_BNU(BN_NUMBER(pMsg), BN_SIZE(pMsg), pOrder, orderLen)), ippStsMessageErr);
- /* test signature value */
- if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignC), BN_SIZE(pSignC), 0) &&
- !cpEqu_BNU_CHUNK(BN_NUMBER(pSignD), BN_SIZE(pSignD), 0) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignC), BN_SIZE(pSignC), pOrder, orderLen) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignD), BN_SIZE(pSignD), pOrder, orderLen)) {
-
- int elmLen = GFP_FELEN(pGFE);
- int pelmLen = GFP_PELEN(pGFE);
-
- BNU_CHUNK_T* h1 = cpGFpGetPool(3, pGFE);
- BNU_CHUNK_T* h2 = h1+pelmLen;
- BNU_CHUNK_T* f = h2+pelmLen;
-
- IppsGFpECPoint P;
- cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
-
- /* P = [d]BasePoint + [c]publicKey */
- ZEXPAND_COPY_BNU(h1, orderLen, BN_NUMBER(pSignD),BN_SIZE(pSignD));
- ZEXPAND_COPY_BNU(h2, orderLen, BN_NUMBER(pSignC),BN_SIZE(pSignC));
- gfec_BasePointProduct(&P,
- h1, orderLen, pRegPublic, h2, orderLen,
- pEC, pScratchBuffer);
-
- /* get P.X */
- if(gfec_GetPoint(h1, NULL, &P, pEC)) {
- /* x = int(P.x) mod order */
- GFP_METHOD(pGFE)->decode(h1, h1, pGFE);
- elmLen = cpMod_BNU(h1, elmLen, pOrder, orderLen);
- cpGFpElementPadd(h1+elmLen, orderLen-elmLen, 0);
-
- /* and recover msg f = (signC -x) mod order */
- ZEXPAND_COPY_BNU(f, orderLen, BN_NUMBER(pMsg),BN_SIZE(pMsg));
- cpModSub_BNU(h1, h2, h1, pOrder, orderLen, h2);
- if(GFP_EQ(f, h1, orderLen))
- vResult = ippECValid;
- }
-
- cpEcGFpReleasePool(1, pEC);
- cpGFpReleasePool(3, pGFE);
- }
-
- *pResult = vResult;
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpecsignsm2.c b/ext/ipp/sources/ippcp/src/pcpgfpecsignsm2.c
deleted file mode 100644
index 25d91e9..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpecsignsm2.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// SM2 signature generation and verification
-//
-// Contents:
-// ippsGFpECSignSM2()
-// ippsGFpECVerifySM2()
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-
-
-/*F*
-// Name: ippsGFpECSignSM2
-//
-// Purpose: SM2 Signature Generation.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPrivate
-// NULL == pEphPrivate
-// NULL == pSignR
-// NULL == pSignS
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pEC->idCtx
-// illegal pMsg->idCtx
-// illegal pRegPrivate->idCtx
-// illegal pEphPrivate->idCtx
-// illegal pSignR->idCtx
-// illegal pSignS->idCtx
-//
-// ippStsMessageErr Msg < 0
-//
-// ippStsRangeErr not enough room for:
-// signR
-// signS
-//
-// ippECInvalidSignature (0==signR)
-// (0==signS)
-// (signR + ephPrivate) == order
-// (1 + regPrivate) == order
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to be signed
-// pRegPrivate pointer to the regular private key
-// pEphPrivate pointer to the ephemeral private key
-// pSignR,pSignS pointer to the signature
-// pEC pointer to the EC context
-// pScratchBuffer pointer to buffer (1 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECSignSM2,(const IppsBigNumState* pMsg,
- const IppsBigNumState* pRegPrivate,
- const IppsBigNumState* pEphPrivate,
- IppsBigNumState* pSignR, IppsBigNumState* pSignS,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pMsg), ippStsMessageErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignS, pSignR);
- pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, ALIGN_VAL) );
- pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pSignR)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
- IPP_BADARG_RET((BN_ROOM(pSignS)*BITSIZE(BNU_CHUNK_T)<ECP_ORDBITSIZE(pEC)), ippStsRangeErr);
-
- /* test private keys */
- IPP_BAD_PTR2_RET(pRegPrivate, pEphPrivate);
- pRegPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRegPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pRegPrivate), ippStsContextMatchErr);
- pEphPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pEphPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pEphPrivate), ippStsContextMatchErr);
-
- {
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- BNU_CHUNK_T* dataR = BN_NUMBER(pSignR);
- BNU_CHUNK_T* dataS = BN_NUMBER(pSignS);
- BNU_CHUNK_T* buffR = BN_BUFFER(pSignR);
- BNU_CHUNK_T* buffS = BN_BUFFER(pSignS);
- BNU_CHUNK_T* buffMsg = BN_BUFFER(pMsg);
-
- /* test value of private keys: regPrivate<order, ephPrivate<order */
- IPP_BADARG_RET(BN_NEGATIVE(pRegPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pRegPrivate), BN_SIZE(pRegPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
- IPP_BADARG_RET(BN_NEGATIVE(pEphPrivate) ||
- (0<=cpCmp_BNU(BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate), pOrder, orderLen)), ippStsIvalidPrivateKey);
-
- /* test value of private key: (regPrivate+1) != order */
- ZEXPAND_COPY_BNU(dataS,orderLen, BN_NUMBER(pRegPrivate),BN_SIZE(pRegPrivate));
- cpInc_BNU(dataS, dataS, orderLen, 1);
- IPP_BADARG_RET(0==cpCmp_BNU(dataS, orderLen, pOrder, orderLen), ippStsIvalidPrivateKey);
-
- {
- int elmLen = GFP_FELEN(pGFE);
- int ns;
-
- /* compute ephemeral public key */
- IppsGFpECPoint ephPublic;
- cpEcGFpInitPoint(&ephPublic, cpEcGFpGetPool(1, pEC), 0, pEC);
- gfec_MulBasePoint(&ephPublic,
- BN_NUMBER(pEphPrivate), BN_SIZE(pEphPrivate),
- pEC, pScratchBuffer);
-
- /* extract X component: ephPublicX = (ephPublic.x) mod order */
- gfec_GetPoint(dataR, NULL, &ephPublic, pEC);
- GFP_METHOD(pGFE)->decode(dataR, dataR, pGFE);
- ns = cpMod_BNU(dataR, elmLen, pOrder, orderLen);
- cpGFpElementPadd(dataR+ns, orderLen-ns, 0);
-
- cpEcGFpReleasePool(1, pEC);
-
- /* reduce message: msg = msg mod ordfer */
- COPY_BNU(buffMsg, BN_NUMBER(pMsg), BN_SIZE(pMsg));
- ns = cpMod_BNU(buffMsg, BN_SIZE(pMsg), pOrder, orderLen);
- ZEXPAND_BNU(buffMsg+ns, orderLen-ns, 0);
-
- /* compute R signature component: r = (msg + ephPublicX) mod order */
- cpModAdd_BNU(dataR, dataR, buffMsg, pOrder, orderLen, buffR);
-
- /* t = (r+ephPrivate) mod order */
- ZEXPAND_COPY_BNU(buffR,orderLen, BN_NUMBER(pEphPrivate),BN_SIZE(pEphPrivate));
- cpModAdd_BNU(buffR, buffR, dataR, pOrder, orderLen, buffS);
-
- /* check r!=0 and t!=0 */
- if(GFP_IS_ZERO(dataR, orderLen) || GFP_IS_ZERO(buffR, orderLen)) return ippStsErr;
-
- /* compute S signature component: S = (1+regPrivate)^1 *(ephPrivate-r*regPrivate) mod order */
- ZEXPAND_COPY_BNU(buffS,orderLen, BN_NUMBER(pRegPrivate),BN_SIZE(pRegPrivate));
- cpMontEnc_BNU_EX(buffR, dataR, orderLen, pMontR); /* r */
- cpMontMul_BNU(buffR, buffR, buffS, /* r*=regPrivate */
- pMontR);
- ZEXPAND_COPY_BNU(buffS,orderLen, BN_NUMBER(pEphPrivate),BN_SIZE(pEphPrivate));
- cpModSub_BNU(buffS, buffS, buffR, pOrder, orderLen, buffR); /* k -=r */
-
- //cpMontInv_BNU(dataS, dataS, pMontR); /* s = (1+regPrivate)^-1 */
- gs_mont_inv(dataS, dataS, pMontR); /* s = (1+regPrivate)^-1 */
- cpMontMul_BNU(dataS, dataS, buffS, pMontR); /* s *= k */
-
- /* check s!=0 */
- if(GFP_IS_ZERO(dataS, orderLen)) return ippStsErr;
-
- /* signR */
- ns = orderLen;
- FIX_BNU(dataR, ns);
- BN_SIGN(pSignR) = ippBigNumPOS;
- BN_SIZE(pSignR) = ns;
- /* signS */
- ns = orderLen;
- FIX_BNU(dataS, ns);
- BN_SIGN(pSignS) = ippBigNumPOS;
- BN_SIZE(pSignS) = ns;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsGFpECVerifySM2
-//
-// Purpose: SM2 Signature Verification.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pEC
-// NULL == pMsg
-// NULL == pRegPublic
-// NULL == pSignR
-// NULL == pSignS
-// NULL == pResult
-// NULL == pScratchBuffer
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pMsgDigest->idCtx
-// illegal pRegPublic->idCtx
-// illegal pSignR->idCtx
-// illegal pSignS->idCtx
-//
-// ippStsMessageErr Msg < 0
-// ippStsRangeErr SignR < 0 or SignS < 0
-//
-// ippStsOutOfRangeErr bitsize(pRegPublic) != bitsize(prime)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the message representative to being signed
-// pRegPublic pointer to the regular public key
-// pSignR,pSignS pointer to the signature
-// pResult pointer to the result: ippECValid/ippECInvalidSignature
-// pEC pointer to the ECCP context
-// pScratchBuffer pointer to buffer (2 mul_point operation)
-//
-*F*/
-IPPFUN(IppStatus, ippsGFpECVerifySM2,(const IppsBigNumState* pMsg,
- const IppsGFpECPoint* pRegPublic,
- const IppsBigNumState* pSignR, const IppsBigNumState* pSignS,
- IppECResult* pResult,
- IppsGFpECState* pEC,
- Ipp8u* pScratchBuffer))
-{
- IppsGFpState* pGF;
- gsModEngine* pGFE;
-
- /* EC context and buffer */
- IPP_BAD_PTR2_RET(pEC, pScratchBuffer);
- pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) );
- IPP_BADARG_RET(!ECP_TEST_ID(pEC), ippStsContextMatchErr);
-
- pGF = ECP_GFP(pEC);
- pGFE = GFP_PMA(pGF);
- IPP_BADARG_RET(1<GFP_EXTDEGREE(pGFE), ippStsNotSupportedModeErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsg);
- pMsg = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsg, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsg), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pMsg), ippStsMessageErr);
-
- /* test regular public key */
- IPP_BAD_PTR1_RET(pRegPublic);
- IPP_BADARG_RET( !ECP_POINT_TEST_ID(pRegPublic), ippStsContextMatchErr );
- IPP_BADARG_RET( ECP_POINT_FELEN(pRegPublic)!=GFP_FELEN(pGFE), ippStsOutOfRangeErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignR, pSignS);
- pSignR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignR, ALIGN_VAL) );
- pSignS = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignS, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignR), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignS), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignR), ippStsRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pSignS), ippStsRangeErr);
-
- /* test result */
- IPP_BAD_PTR1_RET(pResult);
-
- {
- IppECResult vResult = ippECInvalidSignature;
-
- gsModEngine* pMontR = ECP_MONT_R(pEC);
- BNU_CHUNK_T* pOrder = MOD_MODULUS(pMontR);
- int orderLen = MOD_LEN(pMontR);
-
- /* test signature value */
- if(!cpEqu_BNU_CHUNK(BN_NUMBER(pSignR), BN_SIZE(pSignR), 0) &&
- !cpEqu_BNU_CHUNK(BN_NUMBER(pSignS), BN_SIZE(pSignS), 0) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignR), BN_SIZE(pSignR), pOrder, orderLen) &&
- 0>cpCmp_BNU(BN_NUMBER(pSignS), BN_SIZE(pSignS), pOrder, orderLen)) {
-
- int elmLen = GFP_FELEN(pGFE);
- int ns;
-
- BNU_CHUNK_T* r = cpGFpGetPool(4, pGFE);
- BNU_CHUNK_T* s = r+orderLen;
- BNU_CHUNK_T* t = s+orderLen;
- BNU_CHUNK_T* f = t+orderLen;
-
- /* reduce message */
- BNU_CHUNK_T* pMsgData = BN_NUMBER(pMsg);
- BNU_CHUNK_T* pMsgBuff = BN_BUFFER(pMsg);
- int msgLen = BN_SIZE(pMsg);
- COPY_BNU(pMsgBuff, pMsgData, msgLen);
- msgLen = cpMod_BNU(pMsgBuff, msgLen, pOrder, orderLen);
- cpGFpElementPadd(pMsgBuff+msgLen, orderLen-msgLen, 0);
-
- /* expand signatire's components */
- cpGFpElementCopyPadd(r, orderLen, BN_NUMBER(pSignR), BN_SIZE(pSignR));
- cpGFpElementCopyPadd(s, orderLen, BN_NUMBER(pSignS), BN_SIZE(pSignS));
-
- /* t = (r+s) mod order */
- cpModAdd_BNU(t, r, s, pOrder, orderLen, f);
-
- /* P = [s]G +[t]regPublic, t = P.x */
- {
- IppsGFpECPoint P, G;
- cpEcGFpInitPoint(&P, cpEcGFpGetPool(1, pEC),0, pEC);
- cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC);
-
- gfec_BasePointProduct(&P,
- s, orderLen, pRegPublic, t, orderLen,
- pEC, pScratchBuffer);
-
- gfec_GetPoint(t, NULL, &P, pEC);
- GFP_METHOD(pGFE)->decode(t, t, pGFE);
- ns = cpMod_BNU(t, elmLen, pOrder, orderLen);
-
- cpEcGFpReleasePool(1, pEC);
- }
-
- /* t = (msg+t) mod order */
- cpModAdd_BNU(t, t, pMsgBuff, pOrder, orderLen, f);
-
- if(GFP_EQ(t, r, orderLen))
- vResult = ippECValid;
-
- cpGFpReleasePool(4, pGFE);
- }
-
- *pResult = vResult;
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod.h b/ext/ipp/sources/ippcp/src/pcpgfpmethod.h
deleted file mode 100644
index 1891c67..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives
-// Internal GF(p) basic Definitions & Function Prototypes
-//
-*/
-#if !defined(_CP_GFP_METHOD_H)
-#define _CP_GFP_METHOD_H
-
-#include "owncp.h"
-
-#include "pcpbnuimpl.h"
-#include "gsmodmethod.h"
-
-/* modulus ID */
-typedef enum {
- cpID_Prime = 0x1000,
- cpID_PrimeP192r1 = cpID_Prime+6,
- cpID_PrimeP224r1 = cpID_Prime+7,
- cpID_PrimeP256r1 = cpID_Prime+8,
- cpID_PrimeP384r1 = cpID_Prime+9,
- cpID_PrimeP521r1 = cpID_Prime+10,
- cpID_PrimeTPM_SM2 = cpID_Prime+11,
- cpID_PrimeTPM_BN = cpID_Prime+12,
-
- cpID_Poly = 0x10000000, /* id=0x10000000: general polynomial */
- cpID_Binom = 0x01000000, /* id=0x11000000: x^d+a */
-
- cpID_Binom2_epid20 = cpID_Binom|0x220000, /* 0x11220000 */
- cpID_Binom3_epid20 = cpID_Binom|0x230000 /* 0x11230000 */
-
-} cpModulusID;
-
-typedef struct _cpGFpMethod {
- cpModulusID modulusID;
- int modulusBitDeg;
- const BNU_CHUNK_T* modulus;
- const gsModMethod* arith;
-} cpGFpMethod;
-
-/* common GF arith methods */
-#define gsArithGFp OWNAPI(gsArithGFp)
-gsModMethod* gsArithGFp(void);
-
-#endif /* _CP_GFP_METHOD_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_com.c b/ext/ipp/sources/ippcp/src/pcpgfpmethod_com.c
deleted file mode 100644
index c4e3afc..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_com.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p) methods
-//
-*/
-#include "owncp.h"
-
-#include "pcpgfpmethod.h"
-
-/* available pre-defined general methos */
-IPPFUN( const IppsGFpMethod*, ippsGFpMethod_pArb, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Prime,
- 0,
- NULL,
- NULL
- };
- method.arith = gsArithGFp();
- return &method;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpmethod_sm2.c b/ext/ipp/sources/ippcp/src/pcpgfpmethod_sm2.c
deleted file mode 100644
index e7c0c79..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpmethod_sm2.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p) methods
-//
-*/
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpbnumisc.h"
-#include "gsmodstuff.h"
-#include "pcpgfpstuff.h"
-#include "pcpgfpmethod.h"
-#include "pcpecprime.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-#if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
-
-/* arithmetic over 256-bit SM2 modulus */
-BNU_CHUNK_T* sm2_add(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_sub(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_neg(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_div_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_mul_by_2 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_mul_by_3 (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-#if(_IPP_ARCH ==_IPP_ARCH_EM64T)
-BNU_CHUNK_T* sm2_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_sqr_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_sqr_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-#endif
-#if(_IPP_ARCH ==_IPP_ARCH_IA32)
-BNU_CHUNK_T* sm2_mul_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE);
-BNU_CHUNK_T* sm2_sqr_mont_slm(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE);
-void sm2_mred(BNU_CHUNK_T* res, BNU_CHUNK_T* product);
-#endif
-
-#define OPERAND_BITSIZE (256)
-#define LEN_SM2 (BITS_BNU_CHUNK(OPERAND_BITSIZE))
-
-
-/*
-// ia32 multiplicative methods
-*/
-#if (_IPP_ARCH ==_IPP_ARCH_IA32 )
-static BNU_CHUNK_T* sm2_mul_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)
-{
- BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
-
- cpMulAdc_BNU_school(product, pA,LEN_SM2, pB,LEN_SM2);
- sm2_mred(pR, product);
-
- cpGFpReleasePool(2, pGFE);
- return pR;
-}
-
-static BNU_CHUNK_T* sm2_sqr_montl(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
-{
- BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(NULL!=product);
-
- cpSqrAdc_BNU_school(product, pA,LEN_SM2);
- sm2_mred(pR, product);
-
- cpGFpReleasePool(2, pGFE);
- return pR;
-}
-
-
-/*
-// Montgomery domain conversion constants
-*/
-static BNU_CHUNK_T RR[] = {
- 0x00000003,0x00000002, 0xffffffff,0x00000002,
- 0x00000001,0x00000001, 0x00000002,0x00000004};
-
-static BNU_CHUNK_T one[] = {
- 1,0,0,0,0,0,0,0};
-
-static BNU_CHUNK_T* sm2_to_mont(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
-{
- return sm2_mul_montl(pR, pA, (BNU_CHUNK_T*)RR, pGFE);
-}
-
-static BNU_CHUNK_T* sm2_mont_back(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
-{
- return sm2_mul_montl(pR, pA, (BNU_CHUNK_T*)one, pGFE);
-}
-
-static BNU_CHUNK_T* sm2_to_mont_slm(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
-{
- return sm2_mul_mont_slm(pR, pA, (BNU_CHUNK_T*)RR, pGFE);
-}
-
-static BNU_CHUNK_T* sm2_mont_back_slm(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)
-{
- return sm2_mul_mont_slm(pR, pA, (BNU_CHUNK_T*)one, pGFE);
-}
-#endif /* _IPP >= _IPP_P8 */
-
-/*
-// return specific gf p256sm2 arith methods,
-// p256sm2 = 2^256 -2^224 -2^96 +2^64 -1 (SM2 curve)
-*/
-static gsModMethod* gsArithGF_p256sm2(void)
-{
- static gsModMethod m = {
- sm2_to_mont,
- sm2_mont_back,
- sm2_mul_montl,
- sm2_sqr_montl,
- NULL,
- sm2_add,
- sm2_sub,
- sm2_neg,
- sm2_div_by_2,
- sm2_mul_by_2,
- sm2_mul_by_3,
- };
-
- #if(_IPP_ARCH==_IPP_ARCH_EM64T) && ((_ADCOX_NI_ENABLING_==_FEATURE_ON_) || (_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_))
- if(IsFeatureEnabled(ADCOX_ENABLED)) {
- m.mul = sm2_mul_montx;
- m.sqr = sm2_sqr_montx;
- }
- #endif
-
- #if(_IPP_ARCH==_IPP_ARCH_IA32)
- if(IsFeatureEnabled(ippCPUID_SSSE3|ippCPUID_MOVBE) && !IsFeatureEnabled(ippCPUID_AVX)) {
- m.mul = sm2_mul_mont_slm;
- m.sqr = sm2_sqr_mont_slm;
- m.encode = sm2_to_mont_slm;
- m.decode = sm2_mont_back_slm;
- }
- #endif
-
- return &m;
-}
-#endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */
-
-IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p256sm2, (void) )
-{
- static IppsGFpMethod method = {
- cpID_PrimeTPM_SM2,
- 256,
- tpmSM2_p256_p,
- NULL
- };
-
- #if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7)
- method.arith = gsArithGF_p256sm2();
- #else
- method.arith = gsArithGFp();
- #endif
-
- return &method;
-}
-
-#undef LEN_SM2
-#undef OPERAND_BITSIZE
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpstuff.c b/ext/ipp/sources/ippcp/src/pcpgfpstuff.c
deleted file mode 100644
index 6dc394f..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpstuff.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// Internal operations over prime GF(p).
-//
-// Context:
-// cpGFpRand
-// cpGFpSet
-// cpGFpGet
-//
-// cpGFpNeg
-// cpGFpInv
-// cpGFpHalve
-// cpGFpAdd
-// cpGFpSub
-// cpGFpMul
-// cpGFpSqr
-// cpGFpExp, cpGFpExp2
-// cpGFpSqrt
-//
-*/
-#include "owncp.h"
-
-#include "pcpbn.h"
-#include "pcpgfpstuff.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-BNU_CHUNK_T* cpGFpRand(BNU_CHUNK_T* pR, gsModEngine* pGFE, IppBitSupplier rndFunc, void* pRndParam)
-{
- int elemLen = GFP_FELEN(pGFE);
- int reqBitSize = GFP_FEBITLEN(pGFE)+GFP_RAND_ADD_BITS;
- int nsR = (reqBitSize +BITSIZE(BNU_CHUNK_T)-1)/BITSIZE(BNU_CHUNK_T);
-
- int internal_err;
-
- BNU_CHUNK_T* pPool = cpGFpGetPool(2, pGFE);
- //gres: temporary excluded: assert(pPool!=NULL);
-
- cpGFpElementPadd(pPool, nsR, 0);
-
- internal_err = ippStsNoErr != rndFunc((Ipp32u*)pPool, reqBitSize, pRndParam);
-
- if(!internal_err) {
- nsR = cpMod_BNU(pPool, nsR, GFP_MODULUS(pGFE), elemLen);
- cpGFpElementPadd(pPool+nsR, elemLen-nsR, 0);
- GFP_METHOD(pGFE)->encode(pR, pPool, pGFE);
- }
-
- cpGFpReleasePool(2, pGFE);
- return internal_err? NULL : pR;
-}
-
-BNU_CHUNK_T* cpGFpSet(BNU_CHUNK_T* pElm, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFE)
-{
- const BNU_CHUNK_T* pModulus = GFP_MODULUS(pGFE);
- int elemLen = GFP_FELEN(pGFE);
-
- if(0 <= cpCmp_BNU(pDataA, nsA, pModulus, elemLen))
- return NULL;
- else {
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(pTmp !=NULL);
-
- ZEXPAND_COPY_BNU(pTmp, elemLen, pDataA, nsA);
- GFP_METHOD(pGFE)->encode(pElm, pTmp, pGFE);
-
- cpGFpReleasePool(1, pGFE);
- return pElm;
- }
-}
-
-BNU_CHUNK_T* cpGFpGet(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pElm, gsModEngine* pGFE)
-{
- int elemLen = GFP_FELEN(pGFE);
-
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(pTmp !=NULL);
-
- GFP_METHOD(pGFE)->decode(pTmp, pElm, pGFE);
- ZEXPAND_COPY_BNU(pDataA, nsA, pTmp, elemLen);
-
- cpGFpReleasePool(1, pGFE);
- return pDataA;
-}
-
-BNU_CHUNK_T* cpGFpSetOctString(BNU_CHUNK_T* pElm, const Ipp8u* pStr, int strSize, gsModEngine* pGFE)
-{
- int elemLen = GFP_FELEN(pGFE);
-
- if((int)(elemLen*sizeof(BNU_CHUNK_T)) < strSize)
- return NULL;
-
- {
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(pTmp !=NULL);
- {
- int nsTmp = cpFromOctStr_BNU(pTmp, pStr, strSize);
- BNU_CHUNK_T* ret = cpGFpSet(pElm, pTmp, nsTmp, pGFE);
-
- cpGFpReleasePool(1, pGFE);
- return ret==NULL? NULL : pElm;
- }
- }
-}
-
-Ipp8u* cpGFpGetOctString(Ipp8u* pStr, int strSize, const BNU_CHUNK_T* pElm, gsModEngine* pGFE)
-{
- int elemLen = GFP_FELEN(pGFE);
-
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFE);
- //gres: temporary excluded: assert(pTmp !=NULL);
-
- GFP_METHOD(pGFE)->decode(pTmp, pElm, pGFE);
- cpToOctStr_BNU(pStr, strSize, pTmp, elemLen);
-
- cpGFpReleasePool(1, pGFE);
- return pStr;
-}
-
-BNU_CHUNK_T* cpGFpAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->add(pR, pA, pB, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->sub(pR, pA, pB, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->neg(pR, pA, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->mul(pR, pA, pB, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->sqr(pR, pA, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
-{
- return GFP_METHOD(pGFE)->div2(pR, pA, pGFE);
-}
-
-BNU_CHUNK_T* cpGFpInv(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
-{
- GFP_METHOD(pGFE)->decode(pR, pA, pGFE);
- gs_mont_inv(pR, pR, pGFE);
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, gsModEngine* pGFE)
-{
- int elemLen = GFP_FELEN(pGFE);
- cpMontExpBin_BNU(pR, pA,cpFix_BNU(pA, elemLen), pE,cpFix_BNU(pE, nsE), pGFE);
- return pR;
-}
-
-static int factor2(BNU_CHUNK_T* pA, int nsA)
-{
- int factor = 0;
- int bits;
-
- int i;
- for(i=0; i<nsA; i++) {
- int ntz = cpNTZ_BNU(pA[i]);
- factor += ntz;
- if(ntz<BITSIZE(BNU_CHUNK_T))
- break;
- }
-
- bits = factor;
- if(bits >= BITSIZE(BNU_CHUNK_T)) {
- int nchunk = bits/BITSIZE(BNU_CHUNK_T);
- cpGFpElementCopyPadd(pA, nsA, pA+nchunk, nsA-nchunk);
- bits %= BITSIZE(BNU_CHUNK_T);
- }
- if(bits)
- cpLSR_BNU(pA, pA, nsA, bits);
-
- return factor;
-}
-
-static BNU_CHUNK_T* cpGFpExp2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, int e, gsModEngine* pGFE)
-{
- cpGFpElementCopy(pR, pA, GFP_FELEN(pGFE));
- while(e--) {
- GFP_METHOD(pGFE)->sqr(pR, pR, pGFE);
- }
- return pR;
-}
-
-/* returns:
- 0, if a - qnr
- 1, if sqrt is found
-*/
-int cpGFpSqrt(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFE)
-{
- int elemLen = GFP_FELEN(pGFE);
- int poolelementLen = GFP_PELEN(pGFE);
- int resultFlag = 1;
-
- /* case A==0 */
- if( GFP_IS_ZERO(pA, elemLen) )
- cpGFpElementPadd(pR, elemLen, 0);
-
- /* general case */
- else {
- BNU_CHUNK_T* q = cpGFpGetPool(4, pGFE);
- BNU_CHUNK_T* x = q + poolelementLen;
- BNU_CHUNK_T* y = x + poolelementLen;
- BNU_CHUNK_T* z = y + poolelementLen;
-
- int s;
-
- //gres: temporary excluded: assert(q!=NULL);
-
- /* z=1 */
- GFP_ONE(z, elemLen);
-
- /* (modulus-1) = 2^s*q */
- cpSub_BNU(q, GFP_MODULUS(pGFE), z, elemLen);
- s = factor2(q, elemLen);
-
- /*
- // initialization
- */
-
- /* y = qnr^q */
- cpGFpExp(y, GFP_QNR(pGFE), q,elemLen, pGFE);
- /* x = a^((q-1)/2) */
- cpSub_BNU(q, q, z, elemLen);
- cpLSR_BNU(q, q, elemLen, 1);
- cpGFpExp(x, pA, q, elemLen, pGFE);
- /* z = a*x^2 */
- GFP_METHOD(pGFE)->mul(z, x, x, pGFE);
- GFP_METHOD(pGFE)->mul(z, pA, z, pGFE);
- /* R = a*x */
- GFP_METHOD(pGFE)->mul(pR, pA, x, pGFE);
-
- while( !GFP_EQ(z, MOD_MNT_R(pGFE), elemLen) ) {
- int m = 0;
- cpGFpElementCopy(q, z, elemLen);
-
- for(m=1; m<s; m++) {
- GFP_METHOD(pGFE)->mul(q, q, q, pGFE);
- if( GFP_EQ(q, MOD_MNT_R(pGFE), elemLen) )
- break;
- }
-
- if(m==s) {
- /* A is quadratic non-residue */
- resultFlag = 0;
- break;
- }
- else {
- /* exponent reduction */
- cpGFpExp2(q, y, (s-m-1), pGFE); /* q = y^(2^(s-m-1)) */
- GFP_METHOD(pGFE)->mul(y, q, q, pGFE); /* y = q^2 */
- GFP_METHOD(pGFE)->mul(pR, q, pR, pGFE); /* R = q*R */
- GFP_METHOD(pGFE)->mul(z, y, z, pGFE); /* z = z*y */
- s = m;
- }
- }
-
- /* choose smallest between R and (modulus-R) */
- GFP_METHOD(pGFE)->decode(q, pR, pGFE);
- if(GFP_GT(q, GFP_HMODULUS(pGFE), elemLen))
- GFP_METHOD(pGFE)->neg(pR, pR, pGFE);
-
- cpGFpReleasePool(4, pGFE);
- }
-
- return resultFlag;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpx.c b/ext/ipp/sources/ippcp/src/pcpgfpx.c
deleted file mode 100644
index a49f20f..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpx.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// Operations over GF(p) ectension.
-//
-// Context:
-// ippsGFpxGetSize
-// ippsGFpxInit
-// ippsGFpxInitBinomial
-// ippsGFpGetInfo
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpgfpstuff.h"
-#include "pcpgfpxstuff.h"
-#include "pcptool.h"
-
-/* Get context size */
-static int cpGFExGetSize(int elemLen, int pelmLen, int numpe)
-{
- int ctxSize = 0;
-
- /* size of GFp engine */
- ctxSize = sizeof(gsModEngine)
- + elemLen*sizeof(BNU_CHUNK_T) /* modulus */
- + pelmLen*sizeof(BNU_CHUNK_T)*numpe; /* pool */
-
- ctxSize = sizeof(IppsGFpState) /* size of IppsGFPState*/
- + ctxSize; /* GFpx engine */
- return ctxSize;
-}
-
-IPPFUN(IppStatus, ippsGFpxGetSize, (const IppsGFpState* pGroundGF, int deg, int* pSize))
-{
- IPP_BAD_PTR2_RET(pGroundGF, pSize);
- IPP_BADARG_RET( deg<IPP_MIN_GF_EXTDEG || deg >IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
- pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
-
- #define MAX_GFx_SIZE (1<<15) /* max size (bytes) of GF element (32KB) */
- {
- int groundElmLen = GFP_FELEN(GFP_PMA(pGroundGF));
- Ipp64u elmLen64 = (Ipp64u)(groundElmLen) *sizeof(BNU_CHUNK_T) *deg;
- int elemLen = (int)LODWORD(elmLen64);
- *pSize = 0;
- IPP_BADARG_RET(elmLen64> MAX_GFx_SIZE, ippStsBadArgErr);
-
- *pSize = cpGFExGetSize(elemLen, elemLen, GFPX_POOL_SIZE)
- + GFP_ALIGNMENT;
- return ippStsNoErr;
- }
- #undef MAX_GFx_SIZE
-}
-
-/* the "static" specificator removed because of incorrect result under Linux-32, p8
- what's wrong? not know maybe compiler (icl 2017)
- need to check after switchng on icl 2018
- */
-/*static*/ void InitGFpxCtx(const IppsGFpState* pGroundGF, int extDeg, const IppsGFpMethod* method, IppsGFpState* pGFpx)
-{
- gsModEngine* pGFEp = GFP_PMA(pGroundGF);
- int elemLen = extDeg * GFP_FELEN(pGFEp);
- int elemLen32 = extDeg * GFP_FELEN32(pGFEp);
-
- Ipp8u* ptr = (Ipp8u*)pGFpx + sizeof(IppsGFpState);
-
- /* context identifier */
- GFP_ID(pGFpx) = idCtxGFP;
- GFP_PMA(pGFpx) = (gsModEngine*)ptr;
- {
- gsModEngine* pGFEx = GFP_PMA(pGFpx);
-
- /* clear whole context */
- PaddBlock(0, ptr, sizeof(gsModEngine));
- ptr += sizeof(gsModEngine);
-
- GFP_PARENT(pGFEx) = pGFEp;
- GFP_EXTDEGREE(pGFEx) = extDeg;
- GFP_FEBITLEN(pGFEx) = 0;//elemBitLen;
- GFP_FELEN(pGFEx) = elemLen;
- GFP_FELEN32(pGFEx) = elemLen32;
- GFP_PELEN(pGFEx) = elemLen;
- GFP_METHOD(pGFEx) = method->arith;
- GFP_MODULUS(pGFEx) = (BNU_CHUNK_T*)(ptr); ptr += elemLen * sizeof(BNU_CHUNK_T); /* field polynomial */
- GFP_POOL(pGFEx) = (BNU_CHUNK_T*)(ptr); /* pool */
- GFP_MAXPOOL(pGFEx) = GFPX_POOL_SIZE;
- GFP_USEDPOOL(pGFEx) = 0;
-
- cpGFpElementPadd(GFP_MODULUS(pGFEx), elemLen, 0);
- }
-}
-
-
-/*F*
-// Name: ippsGFpxInit
-//
-// Purpose: initializes finite field extension GF(p^d)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGFpx
-// NULL == pGroundGF
-// NULL == ppGroundElm
-// NULL == method
-//
-// ippStsContextMatchErr incorrect pGroundGF's context ID
-// incorrect ppGroundElm[i]'s context ID
-//
-// ippStsOutOfRangeErr size of ppGroundElm[i] does not equal to size of pGroundGF element
-//
-// ippStsBadArgErr IPP_MIN_GF_EXTDEG > extDeg || extDeg > IPP_MAX_GF_EXTDEG
-// (IPP_MIN_GF_EXTDEG==2, IPP_MAX_GF_EXTDEG==8)
-// 1>nElm || nElm>extDeg
-//
-// cpID_Poly!=method->modulusID -- method does not refferenced to polynomial one
-// method->modulusBitDeg!=extDeg -- fixed method does not match to degree extension
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pGroundGF pointer to the context of the finite field is being extension
-// extDeg decgree of extension
-// ppGroundElm[] pointer to the array of extension field polynomial
-// nElm number of coefficients above
-// method pointer to the basic arithmetic metods
-// pGFpx pointer to Finite Field context is being initialized
-*F*/
-IPPFUN(IppStatus, ippsGFpxInit,(const IppsGFpState* pGroundGF, int extDeg,
- const IppsGFpElement* const ppGroundElm[], int nElm,
- const IppsGFpMethod* method, IppsGFpState* pGFpx))
-{
- IPP_BAD_PTR4_RET(pGFpx, pGroundGF, ppGroundElm, method);
-
- pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) );
- pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
-
- /* test extension degree */
- IPP_BADARG_RET( extDeg<IPP_MIN_GF_EXTDEG || extDeg>IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
- /* coeffs at (x^0), (x^1), ..., (x^(deg-1)) passed acually */
- /* considering normilized f(x), the coeff at (x^deg) is 1 and so could neither stored no passed */
- /* test if 1<=nElm<=extDeg */
- IPP_BADARG_RET( 1>nElm || nElm>extDeg, ippStsBadArgErr);
-
- /* test if method is polynomial based */
- IPP_BADARG_RET(cpID_Poly != (method->modulusID & cpID_Poly), ippStsBadArgErr);
- /* test if method is fixed polynomial based */
- IPP_BADARG_RET(method->modulusBitDeg && (method->modulusBitDeg!=extDeg), ippStsBadArgErr);
-
- InitGFpxCtx(pGroundGF, extDeg, method, pGFpx);
-
- {
- BNU_CHUNK_T* pPoly = GFP_MODULUS(GFP_PMA(pGFpx));
- int polyTermlen = GFP_FELEN(GFP_PMA(pGroundGF));
- int n;
- for(n=0; n<nElm; n++, pPoly+=polyTermlen) {
- const IppsGFpElement* pGroundElm = ppGroundElm[n];
-
- /* test element */
- IPP_BAD_PTR1_RET(pGroundElm);
- IPP_BADARG_RET(!GFPE_TEST_ID(pGroundElm), ippStsContextMatchErr);
- IPP_BADARG_RET(GFPE_ROOM(pGroundElm)!=polyTermlen, ippStsOutOfRangeErr);
-
- /* copy element */
- cpGFpElementCopy(pPoly, GFPE_DATA(pGroundElm), polyTermlen);
- }
- }
-
- return ippStsNoErr;
-}
-
-/*F*
-// Name: ippsGFpxInitBinomial
-//
-// Purpose: initializes finite field extension GF(p^d)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pGFpx
-// NULL == pGroundGF
-// NULL == ppGroundElm
-// NULL == method
-//
-// ippStsContextMatchErr incorrect pGroundGF's context ID
-// incorrect pGroundElm's context ID
-//
-// ippStsOutOfRangeErr size of ppGroundElm does not equal to size of pGroundGF element
-//
-// ippStsBadArgErr IPP_MIN_GF_EXTDEG > extDeg || extDeg > IPP_MAX_GF_EXTDEG
-// (IPP_MIN_GF_EXTDEG==2, IPP_MAX_GF_EXTDEG==8)
-//
-// cpID_Poly!=method->modulusID -- method does not refferenced to polynomial one
-// method->modulusBitDeg!=extDeg -- fixed method does not match to degree extension
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pGroundGF pointer to the context of the finite field is being extension
-// extDeg decgree of extension
-// ppGroundElm[] pointer to the array of extension field polynomial
-// nElm number of coefficients above
-// method pointer to the basic arithmetic metods
-// pGFpx pointer to Finite Field context is being initialized
-*F*/
-IPPFUN(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, int extDeg,
- const IppsGFpElement* pGroundElm,
- const IppsGFpMethod* method,
- IppsGFpState* pGFpx))
-{
- IPP_BAD_PTR4_RET(pGFpx, pGroundGF, pGroundElm, method);
-
- pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) );
- pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) );
- IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr );
-
- IPP_BADARG_RET( !GFPE_TEST_ID(pGroundElm), ippStsContextMatchErr );
- IPP_BADARG_RET(GFPE_ROOM(pGroundElm)!=GFP_FELEN(GFP_PMA(pGroundGF)), ippStsOutOfRangeErr);
-
- IPP_BADARG_RET( extDeg<IPP_MIN_GF_EXTDEG || extDeg>IPP_MAX_GF_EXTDEG, ippStsBadArgErr);
-
- /* test method is binomial based */
- IPP_BADARG_RET(cpID_Binom != (method->modulusID & cpID_Binom), ippStsBadArgErr);
-
- /* test if method assums fixed degree extension */
- IPP_BADARG_RET(method->modulusBitDeg && (extDeg!=method->modulusBitDeg), ippStsBadArgErr);
-
- /* init context */
- InitGFpxCtx(pGroundGF, extDeg, method, pGFpx);
-
- /* store low-order coefficient of irresucible into the context */
- cpGFpElementCopy(GFP_MODULUS(GFP_PMA(pGFpx)), GFPE_DATA(pGroundElm), GFP_FELEN(GFP_PMA(pGroundGF)));
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom.c b/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom.c
deleted file mode 100644
index ca62dbd..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom.c
+++ /dev/null
@@ -1,442 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p^d) methods, if binomial generator
-//
-*/
-#include "owncp.h"
-
-#include "pcpgfpxstuff.h"
-#include "pcpgfpxmethod_com.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-static BNU_CHUNK_T* cpGFpxMul_G0(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
-
- BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx); /* g(x) = t^d + g0 */
-
- #if defined GS_DBG
- BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
- BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
- int groundElemLen = GFP_FELEN(pGroundGFE);
- #endif
-
- #if defined GS_DBG
- cpGFpxGet(arg0, groundElemLen, pA, pGroundGFE);
- cpGFpxGet(arg1, groundElemLen, pGFpolynomial, pGroundGFE);
- #endif
-
- mulF(pR, pA, pGFpolynomial, pGroundGFE);
-
- #if defined GS_DBG
- cpGFpReleasePool(2, pGroundGFE);
- #endif
-
- return pR;
-}
-
-/*
-// Multiplication in GF(p^2), if field polynomial: g(x) = x^2 + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxMul_p2_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
-
- const BNU_CHUNK_T* pB0 = pB;
- const BNU_CHUNK_T* pB1 = pB+groundElemLen;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(4, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* t2 = t1+groundElemLen;
- BNU_CHUNK_T* t3 = t2+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- #if defined GS_DBG
- BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
- BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
- #endif
- #if defined GS_DBG
- cpGFpxGet(arg0, groundElemLen, pA0, pGroundGFE);
- cpGFpxGet(arg1, groundElemLen, pB0, pGroundGFE);
- #endif
-
- mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
-
- #if defined GS_DBG
- cpGFpxGet(arg0, groundElemLen, pA1, pGroundGFE);
- cpGFpxGet(arg1, groundElemLen, pB1, pGroundGFE);
- #endif
-
- mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
- addF(t2, pA0, pA1, pGroundGFE); /* t2 = a[0]+a[1] */
- addF(t3, pB0, pB1, pGroundGFE); /* t3 = b[0]+b[1] */
-
- #if defined GS_DBG
- cpGFpxGet(arg0, groundElemLen, t2, pGroundGFE);
- cpGFpxGet(arg1, groundElemLen, t3, pGroundGFE);
- #endif
-
- mulF(pR1, t2, t3, pGroundGFE); /* r[1] = (a[0]+a[1]) * (b[0]+b[1]) */
- subF(pR1, pR1, t0, pGroundGFE); /* r[1] -= a[0]*b[0]) + a[1]*b[1] */
- subF(pR1, pR1, t1, pGroundGFE);
-
- cpGFpxMul_G0(t1, t1, pGFEx);
- subF(pR0, t0, t1, pGroundGFE);
-
- #if defined GS_DBG
- cpGFpReleasePool(2, pGroundGFE);
- #endif
-
- cpGFpReleasePool(4, pGroundGFE);
- return pR;
-}
-
-/*
-// Squaring in GF(p^2), if field polynomial: g(x) = x^2 + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxSqr_p2_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(3, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* u0 = t1+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- #if defined GS_DBG
- BNU_CHUNK_T* arg0 = cpGFpGetPool(1, pGroundGFE);
- BNU_CHUNK_T* arg1 = cpGFpGetPool(1, pGroundGFE);
- #endif
- #if defined GS_DBG
- cpGFpxGet(arg0, groundElemLen, pA0, pGroundGFE);
- cpGFpxGet(arg1, groundElemLen, pA1, pGroundGFE);
- #endif
-
- mulF(u0, pA0, pA1, pGroundGFE); /* u0 = a[0]*a[1] */
- sqrF(t0, pA0, pGroundGFE); /* t0 = a[0]*a[0] */
- sqrF(t1, pA1, pGroundGFE); /* t1 = a[1]*a[1] */
- cpGFpxMul_G0(t1, t1, pGFEx);
- subF(pR0, t0, t1, pGroundGFE);
- addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
-
- #if defined GS_DBG
- cpGFpReleasePool(2, pGroundGFE);
- #endif
-
- cpGFpReleasePool(3, pGroundGFE);
- return pR;
-}
-
-/*
-// return specific polynomi alarith methods
-// polynomial - deg 2 binomial
-*/
-static gsModMethod* gsPolyArith_binom2(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_p2_binom,
- cpGFpxSqr_p2_binom,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom2, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Binom,
- 2,
- NULL,
- NULL
- };
- method.arith = gsPolyArith_binom2();
- return &method;
-}
-
-
-/*
-// Multiplication in GF(p^3), if field polynomial: g(x) = x^3 + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxMul_p3_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
- const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
-
- const BNU_CHUNK_T* pB0 = pB;
- const BNU_CHUNK_T* pB1 = pB+groundElemLen;
- const BNU_CHUNK_T* pB2 = pB+groundElemLen*2;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
- BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(6, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* t2 = t1+groundElemLen;
- BNU_CHUNK_T* u0 = t2+groundElemLen;
- BNU_CHUNK_T* u1 = u0+groundElemLen;
- BNU_CHUNK_T* u2 = u1+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- addF(u0 ,pA0, pA1, pGroundGFE); /* u0 = a[0]+a[1] */
- addF(t0 ,pB0, pB1, pGroundGFE); /* t0 = b[0]+b[1] */
- mulF(u0, u0, t0, pGroundGFE); /* u0 = (a[0]+a[1])*(b[0]+b[1]) */
- mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
-
- addF(u1 ,pA1, pA2, pGroundGFE); /* u1 = a[1]+a[2] */
- addF(t1 ,pB1, pB2, pGroundGFE); /* t1 = b[1]+b[2] */
- mulF(u1, u1, t1, pGroundGFE); /* u1 = (a[1]+a[2])*(b[1]+b[2]) */
- mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
-
- addF(u2 ,pA2, pA0, pGroundGFE); /* u2 = a[2]+a[0] */
- addF(t2 ,pB2, pB0, pGroundGFE); /* t2 = b[2]+b[0] */
- mulF(u2, u2, t2, pGroundGFE); /* u2 = (a[2]+a[0])*(b[2]+b[0]) */
- mulF(t2, pA2, pB2, pGroundGFE); /* t2 = a[2]*b[2] */
-
- subF(u0, u0, t0, pGroundGFE); /* u0 = a[0]*b[1]+a[1]*b[0] */
- subF(u0, u0, t1, pGroundGFE);
- subF(u1, u1, t1, pGroundGFE); /* u1 = a[1]*b[2]+a[2]*b[1] */
- subF(u1, u1, t2, pGroundGFE);
- subF(u2, u2, t2, pGroundGFE); /* u2 = a[2]*b[0]+a[0]*b[2] */
- subF(u2, u2, t0, pGroundGFE);
-
- cpGFpxMul_G0(u1, u1, pGFEx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */
- cpGFpxMul_G0(t2, t2, pGFEx); /* t2 = a[2]*b[2] * beta */
-
- subF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
- subF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
-
- addF(pR2, u2, t1, pGroundGFE); /* r[2] = a[2]*b[0] + a[1]*b[1] + a[0]*b[2] */
-
- cpGFpReleasePool(6, pGroundGFE);
- return pR;
-}
-
-/*
-// Squaring in GF(p^3), if field polynomial: g(x) = x^3 + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxSqr_p3_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
- const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
- BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
-
- BNU_CHUNK_T* s0 = cpGFpGetPool(5, pGroundGFE);
- BNU_CHUNK_T* s1 = s0+groundElemLen;
- BNU_CHUNK_T* s2 = s1+groundElemLen;
- BNU_CHUNK_T* s3 = s2+groundElemLen;
- BNU_CHUNK_T* s4 = s3+groundElemLen;
- //gres: temporary excluded: assert(NULL!=s0);
-
- addF(s2, pA0, pA2, pGroundGFE);
- subF(s2, s2, pA1, pGroundGFE);
- sqrF(s2, s2, pGroundGFE);
- sqrF(s0, pA0, pGroundGFE);
- sqrF(s4, pA2, pGroundGFE);
- mulF(s1, pA0, pA1, pGroundGFE);
- mulF(s3, pA1, pA2, pGroundGFE);
- addF(s1, s1, s1, pGroundGFE);
- addF(s3, s3, s3, pGroundGFE);
-
- addF(pR2, s1, s2, pGroundGFE);
- addF(pR2, pR2, s3, pGroundGFE);
- subF(pR2, pR2, s0, pGroundGFE);
- subF(pR2, pR2, s4, pGroundGFE);
-
- cpGFpxMul_G0(s4, s4, pGFEx);
- subF(pR1, s1, s4, pGroundGFE);
-
- cpGFpxMul_G0(s3, s3, pGFEx);
- subF(pR0, s0, s3, pGroundGFE);
-
- cpGFpReleasePool(5, pGroundGFE);
- return pR;
-}
-
-
-/*
-// return specific polynomi alarith methods
-// polynomial - deg 3 binomial
-*/
-static gsModMethod* gsPolyArith_binom3(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_p3_binom,
- cpGFpxSqr_p3_binom,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-/*
-// returns methods
-*/
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom3, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Binom,
- 3,
- NULL,
- NULL
- };
- method.arith = gsPolyArith_binom3();
- return &method;
-}
-
-
-/*
-// Multiplication in GF(p^d), if field polynomial: g(x) = x^d + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxMul_pd_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
- int deg = GFP_EXTDEGREE(pGFEx);
- int elemLen= GFP_FELEN(pGFEx);
- int groundElemLen = GFP_FELEN(GFP_PARENT(pGFEx));
- int d;
-
- BNU_CHUNK_T* R = cpGFpGetPool(4, pGFEx);
- BNU_CHUNK_T* X = R+elemLen;
- BNU_CHUNK_T* T0= X+elemLen;
- BNU_CHUNK_T* T1= T0+elemLen;
- //gres: temporary excluded: assert(NULL!=R);
-
- /* T0 = A * beta */
- cpGFpxMul_GFE(T0, pA, pGFpolynomial, pGFEx);
- /* T1 = A */
- cpGFpElementCopy(T1, pA, elemLen);
-
- /* R = A * B[0] */
- cpGFpxMul_GFE(R, pA, pB, pGFEx);
-
- /* R += (A*B[d]) mod g() */
- for(d=1; d<deg; d++) {
- cpGFpxMul_GFE(X, GFPX_IDX_ELEMENT(T0, deg-d, groundElemLen), GFPX_IDX_ELEMENT(pB, d, groundElemLen), pGFEx);
- GFP_METHOD(pGFEx)->add(R, R, X, pGFEx);
- }
- cpGFpElementCopy(pR, R, elemLen);
-
- cpGFpReleasePool(4, pGFEx);
- return pR;
-}
-
-/*
-// Squaring in GF(p^d), if field polynomial: g(x) = x^d + beta => binominal
-*/
-static BNU_CHUNK_T* cpGFpxSqr_pd_binom(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- return cpGFpxMul_pd_binom(pR, pA, pA, pGFEx);
-}
-
-/*
-// return specific polynomial arith methods
-// polynomial - general binomial
-*/
-static gsModMethod* gsPolyArith_binom(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_pd_binom,
- cpGFpxSqr_pd_binom,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Binom,
- 0,
- NULL,
- NULL
- };
- method.arith = gsPolyArith_binom();
- return &method;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom_epid2.c b/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom_epid2.c
deleted file mode 100644
index 6bb13bc..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_binom_epid2.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p^d) methods, if binomial generator
-//
-*/
-#include "owncp.h"
-
-#include "pcpgfpxstuff.h"
-#include "pcpgfpxmethod_com.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-/*
-// EPID 2.0 specific.
-//
-// EPID 2.0 uses the following finite field hierarchy:
-//
-// 1) prime field GF(p),
-// p = 0xFFFFFFFFFFFCF0CD46E5F25EEE71A49F0CDC65FB12980A82D3292DDBAED33013
-//
-// 2) 2-degree extension of GF(p): GF(p^2) == GF(p)[x]/g(x), g(x) = x^2 -beta,
-// beta =-1 mod p, so "beta" represents as {1}
-//
-// 3) 3-degree extension of GF(p^2) ~ GF(p^6): GF((p^2)^3) == GF(p)[v]/g(v), g(v) = v^3 -xi,
-// xi belongs GF(p^2), xi=x+2, so "xi" represents as {2,1} ---- "2" is low- and "1" is high-order coefficients
-//
-// 4) 2-degree extension of GF((p^2)^3) ~ GF(p^12): GF(((p^2)^3)^2) == GF(p)[w]/g(w), g(w) = w^2 -vi,
-// psi belongs GF((p^2)^3), vi=0*v^2 +1*v +0, so "vi" represents as {0,1,0}---- "0", '1" and "0" are low-, middle- and high-order coefficients
-//
-// See representations in t_gfpparam.cpp
-//
-*/
-
-/*
-// Multiplication case: mul(a, xi) over GF(p^2),
-// where:
-// a, belongs to GF(p^2)
-// xi belongs to GF(p^2), xi={2,1}
-//
-// The case is important in GF((p^2)^3) arithmetic for EPID 2.0.
-//
-*/
-__INLINE BNU_CHUNK_T* cpFq2Mul_xi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- int termLen = GFP_FELEN(pGroundGFE);
- BNU_CHUNK_T* t0 = cpGFpGetPool(2, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+termLen;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+termLen;
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+termLen;
-
- //gres: temporary excluded: assert(NULL!=t0);
- addF(t0, pA0, pA0, pGroundGFE);
- addF(t1, pA0, pA1, pGroundGFE);
- subF(pR0, t0, pA1, pGroundGFE);
- addF(pR1, t1, pA1, pGroundGFE);
-
- cpGFpReleasePool(2, pGroundGFE);
- return pR;
-}
-
-/*
-// Multiplication case: mul(a, vi) over GF((p^2)^3),
-// where:
-// a, belongs to GF((p^2)^3)
-// xi belongs to GF((p^2)^3), vi={0,1,0}
-//
-// The case is important in GF(((p^2)^3)^2) arithmetic for EPID 2.0.
-//
-*/
-__INLINE BNU_CHUNK_T* cpFq6Mul_vi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int termLen = GFP_FELEN(pGroundGFE);
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+termLen;
- const BNU_CHUNK_T* pA2 = pA+termLen*2;
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+termLen;
- BNU_CHUNK_T* pR2 = pR+termLen*2;
-
- BNU_CHUNK_T* t = cpGFpGetPool(1, pGroundGFE);
- //gres: temporary excluded: assert(NULL!=t);
-
- cpFq2Mul_xi(t, pA2, pGroundGFE);
- cpGFpElementCopy(pR2, pA1, termLen);
- cpGFpElementCopy(pR1, pA0, termLen);
- cpGFpElementCopy(pR0, t, termLen);
-
- cpGFpReleasePool(1, pGroundGFE);
-
- return pR;
-}
-
-/*
-// Multiplication case: mul(a, g0) over GF(()),
-// where:
-// a and g0 belongs to GF(()) - field is being extension
-//
-// The case is important in GF(()^d) arithmetic if constructed polynomial is generic binomial g(t) = t^d +g0.
-//
-*/
-static BNU_CHUNK_T* cpGFpxMul_G0(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx); /* g(x) = t^d + g0 */
- return GFP_METHOD(pGroundGFE)->mul(pR, pA, pGFpolynomial, pGroundGFE);
-}
-
-/*
-// EPID20 specific
-// ~~~~~~~~~~~~~~~
-//
-// Multiplication over GF(p^2)
-// - field polynomial: g(x) = x^2 - beta => binominal with specific value of "beta"
-// - beta = p-1
-//
-// Multiplication over GF(((p^2)^3)^2) ~ GF(p^12)
-// - field polynomial: g(w) = w^2 - vi => binominal with specific value of "vi"
-// - vi = 0*v^2 + 1*v + 0 - i.e vi={0,1,0} belongs to GF((p^2)^3)
-*/
-static BNU_CHUNK_T* cpGFpxMul_p2_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
-
- const BNU_CHUNK_T* pB0 = pB;
- const BNU_CHUNK_T* pB1 = pB+groundElemLen;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(4, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* t2 = t1+groundElemLen;
- BNU_CHUNK_T* t3 = t2+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
- mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
- addF(t2, pA0, pA1, pGroundGFE); /* t2 = a[0]+a[1] */
- addF(t3, pB0, pB1, pGroundGFE); /* t3 = b[0]+b[1] */
-
- mulF(pR1, t2, t3, pGroundGFE); /* r[1] = (a[0]+a[1]) * (b[0]+b[1]) */
- subF(pR1, pR1, t0, pGroundGFE); /* r[1] -= a[0]*b[0]) + a[1]*b[1] */
- subF(pR1, pR1, t1, pGroundGFE);
-
- /* EPID2 specific */
- {
- int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
-
- /* deal with GF(p^2) */
- if(basicExtDegree==2) {
- subF(pR0, t0, t1, pGroundGFE);
- }
- /* deal with GF(p^6^2) */
- else if(basicExtDegree==12) {
- cpFq6Mul_vi(t1, t1, pGroundGFE);
- addF(pR0, t0, t1, pGroundGFE);
- }
- /* deal with GF(p^x^2) - it's not EPID2 case, just a case */
- else {
- cpGFpxMul_G0(t1, t1, pGFEx);
- subF(pR0, t0, t1, pGroundGFE);
- }
- }
-
- cpGFpReleasePool(4, pGroundGFE);
- return pR;
-}
-
-/*
-// EPID20 specific
-// ~~~~~~~~~~~~~~~
-//
-// Squaring over GF(p^2)
-// - field polynomial: g(x) = x^2 - beta => binominal with specific value of "beta"
-// - beta = p-1
-//
-// Squaring in GF(((p^2)^3)^2) ~ GF(p^12)
-// - field polynomial: g(w) = w^2 - vi => binominal with specific value of "vi"
-// - vi = 0*v^2 + 1*v + 0 - i.e vi={0,1,0} belongs to GF((p^2)^3)
-*/
-static BNU_CHUNK_T* cpGFpxSqr_p2_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(3, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* u0 = t1+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- mulF(u0, pA0, pA1, pGroundGFE); /* u0 = a[0]*a[1] */
-
- /* EPID2 specific */
- {
- int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
-
- /* deal with GF(p^2) */
- if(basicExtDegree==2) {
- addF(t0, pA0, pA1, pGroundGFE);
- subF(t1, pA0, pA1, pGroundGFE);
- mulF(pR0, t0, t1, pGroundGFE);
- addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
- }
- /* deal with GF(p^6^2) */
- else if(basicExtDegree==12) {
- subF(t0, pA0, pA1, pGroundGFE);
- cpFq6Mul_vi(t1, pA1, pGroundGFE);
- subF(t1, pA0, t1, pGroundGFE);
- mulF(t0, t0, t1, pGroundGFE);
- addF(t0, t0, u0, pGroundGFE);
- cpFq6Mul_vi(t1, u0, pGroundGFE);
- addF(pR0, t0, t1, pGroundGFE);
- addF(pR1, u0, u0, pGroundGFE);
- }
- /* just a case */
- else {
- sqrF(t0, pA0, pGroundGFE); /* t0 = a[0]*a[0] */
- sqrF(t1, pA1, pGroundGFE); /* t1 = a[1]*a[1] */
- cpGFpxMul_G0(t1, t1, pGFEx);
- subF(pR0, t0, t1, pGroundGFE);
- addF(pR1, u0, u0, pGroundGFE); /* r[1] = 2*a[0]*a[1] */
- }
- }
-
- cpGFpReleasePool(3, pGroundGFE);
- return pR;
-}
-
-/*
-// return specific polynomi alarith methods
-// polynomial - deg 2 binomial (EPID 2.0)
-*/
-static gsModMethod* gsPolyArith_binom2_epid2(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_p2_binom_epid2,
- cpGFpxSqr_p2_binom_epid2,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom2_epid2, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Binom2_epid20,
- 2,
- NULL,
- NULL
- };
- method.arith = gsPolyArith_binom2_epid2();
- return &method;
-}
-
-
-/*
-// EPID20 specific
-// ~~~~~~~~~~~~~~~
-//
-// Multiplication over GF((p^2)^3)
-// - field polynomial: g(v) = v^3 - xi => binominal with specific value of "xi"
-// - xi = x+2
-*/
-static BNU_CHUNK_T* cpGFpxMul_p3_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
- const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
-
- const BNU_CHUNK_T* pB0 = pB;
- const BNU_CHUNK_T* pB1 = pB+groundElemLen;
- const BNU_CHUNK_T* pB2 = pB+groundElemLen*2;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
- BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
-
- BNU_CHUNK_T* t0 = cpGFpGetPool(6, pGroundGFE);
- BNU_CHUNK_T* t1 = t0+groundElemLen;
- BNU_CHUNK_T* t2 = t1+groundElemLen;
- BNU_CHUNK_T* u0 = t2+groundElemLen;
- BNU_CHUNK_T* u1 = u0+groundElemLen;
- BNU_CHUNK_T* u2 = u1+groundElemLen;
- //gres: temporary excluded: assert(NULL!=t0);
-
- addF(u0 ,pA0, pA1, pGroundGFE); /* u0 = a[0]+a[1] */
- addF(t0 ,pB0, pB1, pGroundGFE); /* t0 = b[0]+b[1] */
- mulF(u0, u0, t0, pGroundGFE); /* u0 = (a[0]+a[1])*(b[0]+b[1]) */
- mulF(t0, pA0, pB0, pGroundGFE); /* t0 = a[0]*b[0] */
-
- addF(u1 ,pA1, pA2, pGroundGFE); /* u1 = a[1]+a[2] */
- addF(t1 ,pB1, pB2, pGroundGFE); /* t1 = b[1]+b[2] */
- mulF(u1, u1, t1, pGroundGFE); /* u1 = (a[1]+a[2])*(b[1]+b[2]) */
- mulF(t1, pA1, pB1, pGroundGFE); /* t1 = a[1]*b[1] */
-
- addF(u2 ,pA2, pA0, pGroundGFE); /* u2 = a[2]+a[0] */
- addF(t2 ,pB2, pB0, pGroundGFE); /* t2 = b[2]+b[0] */
- mulF(u2, u2, t2, pGroundGFE); /* u2 = (a[2]+a[0])*(b[2]+b[0]) */
- mulF(t2, pA2, pB2, pGroundGFE); /* t2 = a[2]*b[2] */
-
- subF(u0, u0, t0, pGroundGFE); /* u0 = a[0]*b[1]+a[1]*b[0] */
- subF(u0, u0, t1, pGroundGFE);
- subF(u1, u1, t1, pGroundGFE); /* u1 = a[1]*b[2]+a[2]*b[1] */
- subF(u1, u1, t2, pGroundGFE);
- subF(u2, u2, t2, pGroundGFE); /* u2 = a[2]*b[0]+a[0]*b[2] */
- subF(u2, u2, t0, pGroundGFE);
-
- /* EPID2 specific */
- {
- int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
-
- /* deal with GF(p^2^3) */
- if(basicExtDegree==6) {
- cpFq2Mul_xi(u1, u1, pGroundGFE);
- cpFq2Mul_xi(t2, t2, pGroundGFE);
- addF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
- addF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
- }
- /* just a case */
- else {
- cpGFpxMul_G0(u1, u1, pGFEx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */
- cpGFpxMul_G0(t2, t2, pGFEx); /* t2 = a[2]*b[2] * beta */
- subF(pR0, t0, u1, pGroundGFE); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */
- subF(pR1, u0, t2, pGroundGFE); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */
- }
- }
-
- addF(pR2, u2, t1, pGroundGFE); /* r[2] = a[2]*b[0] + a[1]*b[1] + a[0]*b[2] */
-
- cpGFpReleasePool(6, pGroundGFE);
- return pR;
-}
-
-/*
-// EPID20 specific
-// ~~~~~~~~~~~~~~~
-//
-// Squaring over GF((p^2)^3)
-// - field polynomial: g(v) = v^3 - xi => binominal with specific value of "xi"
-// - xi = x+2
-*/
-static BNU_CHUNK_T* cpGFpxSqr_p3_binom_epid2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sqr sqrF = GFP_METHOD(pGroundGFE)->sqr;
- mod_add addF = GFP_METHOD(pGroundGFE)->add;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- const BNU_CHUNK_T* pA0 = pA;
- const BNU_CHUNK_T* pA1 = pA+groundElemLen;
- const BNU_CHUNK_T* pA2 = pA+groundElemLen*2;
-
- BNU_CHUNK_T* pR0 = pR;
- BNU_CHUNK_T* pR1 = pR+groundElemLen;
- BNU_CHUNK_T* pR2 = pR+groundElemLen*2;
-
- BNU_CHUNK_T* s0 = cpGFpGetPool(5, pGroundGFE);
- BNU_CHUNK_T* s1 = s0+groundElemLen;
- BNU_CHUNK_T* s2 = s1+groundElemLen;
- BNU_CHUNK_T* s3 = s2+groundElemLen;
- BNU_CHUNK_T* s4 = s3+groundElemLen;
-
- addF(s2, pA0, pA2, pGroundGFE);
- subF(s2, s2, pA1, pGroundGFE);
- sqrF(s2, s2, pGroundGFE);
- sqrF(s0, pA0, pGroundGFE);
- sqrF(s4, pA2, pGroundGFE);
- mulF(s1, pA0, pA1, pGroundGFE);
- mulF(s3, pA1, pA2, pGroundGFE);
- addF(s1, s1, s1, pGroundGFE);
- addF(s3, s3, s3, pGroundGFE);
-
- addF(pR2, s1, s2, pGroundGFE);
- addF(pR2, pR2, s3, pGroundGFE);
- subF(pR2, pR2, s0, pGroundGFE);
- subF(pR2, pR2, s4, pGroundGFE);
-
- /* EPID2 specific */
- {
- int basicExtDegree = cpGFpBasicDegreeExtension(pGFEx);
-
- /* deal with GF(p^2^3) */
- if(basicExtDegree==6) {
- cpFq2Mul_xi(s4, s4, pGroundGFE);
- cpFq2Mul_xi(s3, s3, pGroundGFE);
- addF(pR1, s1, s4, pGroundGFE);
- addF(pR0, s0, s3, pGroundGFE);
- }
- /* just a case */
- else {
- cpGFpxMul_G0(s4, s4, pGFEx);
- cpGFpxMul_G0(s3, s3, pGFEx);
- subF(pR1, s1, s4, pGroundGFE);
- subF(pR0, s0, s3, pGroundGFE);
- }
- }
-
- cpGFpReleasePool(5, pGroundGFE);
- return pR;
-}
-
-/*
-// return specific polynomi alarith methods
-// polynomial - deg 3 binomial (EPID 2.0)
-*/
-static gsModMethod* gsPolyArith_binom3_epid2(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_p3_binom_epid2,
- cpGFpxSqr_p3_binom_epid2,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_binom3_epid2, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Binom3_epid20,
- 3,
- NULL,
- NULL
- };
- method.arith = gsPolyArith_binom3_epid2();
- return &method;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.c b/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.c
deleted file mode 100644
index 094c16f..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p^d) methods
-//
-*/
-#include "owncp.h"
-
-#include "pcpgfpxstuff.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-
-BNU_CHUNK_T* cpGFpxAdd_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_add addF = GFP_METHOD(pBasicGFE)->add;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- addF(pTmp, pA, pB, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- pB += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxSub_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_sub subF = GFP_METHOD(pBasicGFE)->sub;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- subF(pTmp, pA, pB, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- pB += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxNeg_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_neg negF = GFP_METHOD(pBasicGFE)->neg;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- negF(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxMul_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx)
-{
- int extDegree = GFP_EXTDEGREE(pGFEx);
-
- BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
- int degR = extDegree-1;
- int elemLen= GFP_FELEN(pGFEx);
-
- int degB = degR;
- BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFEx);
- BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFEx);
-
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGFE);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- const BNU_CHUNK_T* pTmpB = GFPX_IDX_ELEMENT(pB, degB, groundElemLen);
-
- //gres: temporary excluded: assert(NULL!=pTmpProduct && NULL!=r);
-
- /* clear temporary */
- cpGFpElementPadd(pTmpProduct, elemLen, 0);
-
- /* R = A * B[degB-1] */
- cpGFpxMul_GFE(pTmpResult, pA, pTmpB, pGFEx);
-
- for(degB-=1; degB>=0; degB--) {
- /* save R[degR-1] */
- cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen);
-
- { /* R = R * x */
- int j;
- for (j=degR; j>=1; j--)
- cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen);
- cpGFpElementPadd(pTmpResult, groundElemLen, 0);
- }
-
- cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFEx);
- GFP_METHOD(pGFEx)->sub(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
-
- /* B[degB-i] */
- pTmpB -= groundElemLen;
- cpGFpxMul_GFE(pTmpProduct, pA, pTmpB, pGFEx);
- GFP_METHOD(pGFEx)->add(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
- }
-
- /* copy result */
- cpGFpElementCopy(pR, pTmpResult, elemLen);
-
- /* release pools */
- cpGFpReleasePool(1, pGroundGFE);
- cpGFpReleasePool(2, pGFEx);
-
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxSqr_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- int extDegree = GFP_EXTDEGREE(pGFEx);
-
- BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFEx);
- int degR = extDegree-1;
- int elemLen= GFP_FELEN(pGFEx);
-
- int degA = degR;
- BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFEx);
- BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFEx);
-
- gsEngine* pGroundGFE = GFP_PARENT(pGFEx);
- BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGFE);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- const BNU_CHUNK_T* pTmpA = GFPX_IDX_ELEMENT(pA, degA, groundElemLen);
-
- //gres: temporary excluded: assert(NULL!=pTmpProduct && NULL!=r);
-
- /* clear temporary */
- cpGFpElementPadd(pTmpProduct, elemLen, 0);
-
- /* R = A * A[degA-1] */
- cpGFpxMul_GFE(pTmpResult, pA, pTmpA, pGFEx);
-
- for(degA-=1; degA>=0; degA--) {
- /* save R[degR-1] */
- cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen);
-
- { /* R = R * x */
- int j;
- for (j=degR; j>=1; j--)
- cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen);
- cpGFpElementPadd(pTmpResult, groundElemLen, 0);
- }
-
- cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFEx);
- GFP_METHOD(pGFEx)->sub(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
-
- /* A[degA-i] */
- pTmpA -= groundElemLen;
- cpGFpxMul_GFE(pTmpProduct, pA, pTmpA, pGFEx);
- GFP_METHOD(pGFEx)->add(pTmpResult, pTmpResult, pTmpProduct, pGFEx);
- }
-
- /* copy result */
- cpGFpElementCopy(pR, pTmpResult, elemLen);
-
- /* release pools */
- cpGFpReleasePool(1, pGroundGFE);
- cpGFpReleasePool(2, pGFEx);
-
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxDiv2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_div2 div2F = GFP_METHOD(pBasicGFE)->div2;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- div2F(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxMul2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_mul2 mul2F = GFP_METHOD(pBasicGFE)->mul2;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- mul2F(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxMul3_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_mul3 mul3F = GFP_METHOD(pBasicGFE)->mul3;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- mul3F(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxEncode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_encode encodeF = GFP_METHOD(pBasicGFE)->encode;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- encodeF(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxDecode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx)
-{
- gsEngine* pBasicGFE = cpGFpBasic(pGFEx);
- mod_decode decodeF = GFP_METHOD(pBasicGFE)->decode;
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- decodeF(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-/*
-// return common polynomi alarith methods
-*/
-static gsModMethod* gsPolyArith(void)
-{
- static gsModMethod m = {
- cpGFpxEncode_com,
- cpGFpxDecode_com,
- cpGFpxMul_com,
- cpGFpxSqr_com,
- NULL,
- cpGFpxAdd_com,
- cpGFpxSub_com,
- cpGFpxNeg_com,
- cpGFpxDiv2_com,
- cpGFpxMul2_com,
- cpGFpxMul3_com,
- //cpGFpxInv
- };
- return &m;
-}
-
-IPPFUN( const IppsGFpMethod*, ippsGFpxMethod_com, (void) )
-{
- static IppsGFpMethod method = {
- cpID_Poly,
- 0,
- NULL,
- NULL
- };
- method.arith = gsPolyArith();
- return &method;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.h b/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.h
deleted file mode 100644
index df728c2..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpxmethod_com.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// GF(p^d) methods
-//
-*/
-#if !defined(_CP_GFP_METHOD_COM_H)
-#define _CP_GFP_METHOD_COM_H
-
-#include "owncp.h"
-#include "pcpgfpstuff.h"
-
-#define cpGFpxAdd_com OWNAPI(cpGFpxAdd_com)
-BNU_CHUNK_T* cpGFpxAdd_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
-#define cpGFpxSub_com OWNAPI(cpGFpxSub_com)
-BNU_CHUNK_T* cpGFpxSub_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
-#define cpGFpxNeg_com OWNAPI(cpGFpxNeg_com)
-BNU_CHUNK_T* cpGFpxNeg_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-
-#define cpGFpxMul_com OWNAPI(cpGFpxMul_com)
-BNU_CHUNK_T* cpGFpxMul_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFEx);
-#define cpGFpxSqr_com OWNAPI(cpGFpxSqr_com)
-BNU_CHUNK_T* cpGFpxSqr_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-
-#define cpGFpxDiv2_com OWNAPI(cpGFpxDiv2_com)
-BNU_CHUNK_T* cpGFpxDiv2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-#define cpGFpxMul2_com OWNAPI(cpGFpxMul2_com)
-BNU_CHUNK_T* cpGFpxMul2_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-#define cpGFpxMul3_com OWNAPI(cpGFpxMul3_com)
-BNU_CHUNK_T* cpGFpxMul3_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-
-#define cpGFpxEncode_com OWNAPI(cpGFpxEncode_com)
-BNU_CHUNK_T* cpGFpxEncode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-#define cpGFpxDecode_com OWNAPI(cpGFpxDecode_com)
-BNU_CHUNK_T* cpGFpxDecode_com(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFEx);
-
-#endif /* _CP_GFP_METHOD_COM_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpgfpxstuff.c b/ext/ipp/sources/ippcp/src/pcpgfpxstuff.c
deleted file mode 100644
index 625a7da..0000000
--- a/ext/ipp/sources/ippcp/src/pcpgfpxstuff.c
+++ /dev/null
@@ -1,722 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Performance Primitives. Cryptography Primitives.
-// Internal operations over GF(p) extension.
-//
-// Context:
-// cpGFpxRand
-// cpGFpxSet, cpGFpxSetPolyTerm
-// cpGFpxGet, cpGFpxGetPolyTerm
-//
-// cpGFpxNeg
-// cpGFpxInv
-// cpGFpxHalve
-// cpGFpxAdd, cpGFpxAdd_GFE
-// cpGFpxSub, cpGFpxSub_GFE
-// cpGFpxMul, cpGFpxMul_GFE
-// cpGFpxSqr
-// cpGFpxExp, cpGFpxMultiExp
-// cpGFpxConj
-//
-//
-*/
-#include "owncp.h"
-
-#include "pcpbnumisc.h"
-#include "pcpgfpxstuff.h"
-#include "gsscramble.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-
-BNU_CHUNK_T* cpGFpxRand(BNU_CHUNK_T* pR, gsModEngine* pGFEx, IppBitSupplier rndFunc, void* pRndParam)
-{
- if( GFP_IS_BASIC(pGFEx) )
- return cpGFpRand(pR, pGFEx, rndFunc, pRndParam);
-
- else {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- if(NULL == cpGFpRand(pTmp, pBasicGFE, rndFunc, pRndParam))
- break;
- pTmp += basicElemLen;
- }
- return deg==basicDeg? pR : NULL;
- }
-}
-
-BNU_CHUNK_T* cpGFpxSet(BNU_CHUNK_T* pE, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFEx)
-{
- if( GFP_IS_BASIC(pGFEx) )
- return cpGFpSet(pE, pDataA, nsA, pGFEx);
-
- else {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
- int basicElemLen = GFP_FELEN(pBasicGFE);
-
- BNU_CHUNK_T* pTmpE = pE;
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- int deg, error;
- for(deg=0, error=0; deg<basicDeg && !error; deg++) {
- int pieceA = IPP_MIN(nsA, basicElemLen);
-
- error = NULL == cpGFpSet(pTmpE, pDataA, pieceA, pBasicGFE);
- pTmpE += basicElemLen;
- pDataA += pieceA;
- nsA -= pieceA;
- }
-
- return (deg<basicDeg)? NULL : pE;
- }
-}
-
-BNU_CHUNK_T* cpGFpxSetPolyTerm(BNU_CHUNK_T* pE, int deg, const BNU_CHUNK_T* pDataA, int nsA, gsModEngine* pGFEx)
-{
- pE += deg * GFP_FELEN(pGFEx);
- return cpGFpxSet(pE, pDataA, nsA, pGFEx);
-}
-
-BNU_CHUNK_T* cpGFpxGet(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pE, gsModEngine* pGFEx)
-{
- cpGFpElementPadd(pDataA, nsA, 0);
-
- if( GFP_IS_BASIC(pGFEx) )
- return cpGFpGet(pDataA, nsA, pE, pGFEx);
-
- else {
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
- int basicElemLen = GFP_FELEN(pBasicGFE);
-
- BNU_CHUNK_T* pTmp = pDataA;
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- int deg;
- for(deg=0; deg<basicDeg && nsA>0; deg++) {
- int pieceA = IPP_MIN(nsA, basicElemLen);
-
- cpGFpGet(pTmp, pieceA, pE, pBasicGFE);
- pE += basicElemLen;
- pTmp += pieceA;
- nsA -= pieceA;
- }
-
- return pDataA;
- }
-}
-
-BNU_CHUNK_T* cpGFpxGetPolyTerm(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pE, int deg, gsModEngine* pGFEx)
-{
- pE += deg * GFP_FELEN(pGFEx);
- return cpGFpxGet(pDataA, nsA, pE, pGFEx);
-}
-
-BNU_CHUNK_T* cpGFpxConj(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
-{
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int groundElemLen = GFP_FELEN(pGroundGFE);
-
- if(pR != pA)
- cpGFpElementCopy(pR, pA, groundElemLen);
- MOD_METHOD(pGroundGFE)->neg(pR+groundElemLen, pA+groundElemLen, pGroundGFE);
-
- return pR;
-}
-
-
-BNU_CHUNK_T* cpGFpxAdd_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
-{
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_add addF = MOD_METHOD(pGroundGFE)->add;
-
- if(pR != pA) {
- int groundElemLen = GFP_FELEN(pGroundGFE);
- int deg = GFP_EXTDEGREE(pGFEx);
- cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1));
- }
- return addF(pR, pA, pGroundB, pGroundGFE);
-}
-
-BNU_CHUNK_T* cpGFpxSub_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
-{
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_sub subF = MOD_METHOD(pGroundGFE)->sub;
-
- if(pR != pA) {
- int groundElemLen = GFP_FELEN(pGroundGFE);
- int deg = GFP_EXTDEGREE(pGFEx);
- cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1));
- }
- return subF(pR, pA, pGroundB, pGroundGFE);
-}
-
-BNU_CHUNK_T* cpGFpxMul_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, gsModEngine* pGFEx)
-{
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul mulF = MOD_METHOD(pGroundGFE)->mul;
-
- int grounfElemLen = GFP_FELEN(pGroundGFE);
-
- BNU_CHUNK_T* pTmp = pR;
-
- int deg;
- for(deg=0; deg<GFP_EXTDEGREE(pGFEx); deg++) {
- mulF(pTmp, pA, pGroundB, pGroundGFE);
- pTmp += grounfElemLen;
- pA += grounfElemLen;
- }
- return pR;
-}
-
-BNU_CHUNK_T* cpGFpxNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
-{
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
- int basicElemLen = GFP_FELEN(pBasicGFE);
- int basicDeg = cpGFpBasicDegreeExtension(pGFEx);
-
- BNU_CHUNK_T* pTmp = pR;
- int deg;
- for(deg=0; deg<basicDeg; deg++) {
- GFP_METHOD(pBasicGFE)->neg(pTmp, pA, pBasicGFE);
- pTmp += basicElemLen;
- pA += basicElemLen;
- }
- return pR;
-}
-
-static BNU_CHUNK_T* gfpxPolyDiv(BNU_CHUNK_T* pQ, BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pA,
- const BNU_CHUNK_T* pB,
- gsModEngine* pGFEx)
-{
- if( GFP_IS_BASIC(pGFEx) )
- return NULL;
-
- else {
- int elemLen = GFP_FELEN(pGFEx);
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- int termLen = GFP_FELEN(pGroundGFE);
-
- int degA = degree(pA, pGFEx);
- int degB = degree(pB, pGFEx);
-
- if(degB==0) {
- if( GFP_IS_ZERO(pB, termLen) )
- return NULL;
- else {
- gsModEngine* pBasicGFE = cpGFpBasic(pGroundGFE);
-
- cpGFpInv(pR, pB, pBasicGFE);
- cpGFpElementPadd(pR+GFP_FELEN(pGroundGFE), termLen-GFP_FELEN(pGroundGFE), 0);
- cpGFpxMul_GFE(pQ, pA, pR, pGFEx);
- cpGFpElementPadd(pR, elemLen, 0);
- return pR;
- }
- }
-
- if(degA < degB) {
- cpGFpElementPadd(pQ, elemLen, 0);
- cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen);
- return pR;
- }
-
- else {
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- int i, j;
- BNU_CHUNK_T* pProduct = cpGFpGetPool(2, pGroundGFE);
- BNU_CHUNK_T* pInvB = pProduct + GFP_PELEN(pGroundGFE);
- //gres: temporary excluded: assert(NULL!=pProduct);
-
- cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen);
- cpGFpElementPadd(pQ, elemLen, 0);
-
- cpGFpxInv(pInvB, GFPX_IDX_ELEMENT(pB, degB, termLen), pGroundGFE);
-
- for(i=0; i<=degA-degB && !GFP_IS_ZERO(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen); i++) {
- /* compute q term */
- mulF(GFPX_IDX_ELEMENT(pQ, degA-degB-i, termLen),
- GFPX_IDX_ELEMENT(pR, degA-i, termLen),
- pInvB,
- pGroundGFE);
-
- /* R -= B * q */
- cpGFpElementPadd(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen, 0);
- for(j=0; j<degB; j++) {
- mulF(pProduct,
- GFPX_IDX_ELEMENT(pB, j ,termLen),
- GFPX_IDX_ELEMENT(pQ, degA-degB-i, termLen),
- pGroundGFE);
- subF(GFPX_IDX_ELEMENT(pR, degA-degB-i+j, termLen),
- GFPX_IDX_ELEMENT(pR, degA-degB-i+j, termLen),
- pProduct,
- pGroundGFE);
- }
- }
-
- cpGFpReleasePool(2, pGroundGFE);
- return pR;
- }
- }
-}
-
-static BNU_CHUNK_T* gfpxGeneratorDiv(BNU_CHUNK_T* pQ, BNU_CHUNK_T* pR, const BNU_CHUNK_T* pB, gsModEngine* pGFEx)
-{
- if( GFP_IS_BASIC(pGFEx) )
- return NULL;
-
- else {
- int elemLen = GFP_FELEN(pGFEx);
-
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- mod_mul mulF = GFP_METHOD(pGroundGFE)->mul;
- mod_sub subF = GFP_METHOD(pGroundGFE)->sub;
-
- int termLen = GFP_FELEN(pGroundGFE);
-
- BNU_CHUNK_T* pInvB = cpGFpGetPool(2, pGroundGFE);
- BNU_CHUNK_T* pTmp = pInvB + GFP_PELEN(pGroundGFE);
-
- int degB = degree(pB, pGFEx);
- int i;
-
- //gres: temporary excluded: assert(NULL!=pInvB);
-
- cpGFpElementCopy(pR, GFP_MODULUS(pGFEx), elemLen);
- cpGFpElementPadd(pQ, elemLen, 0);
-
- cpGFpxInv(pInvB, GFPX_IDX_ELEMENT(pB, degB, termLen), pGroundGFE);
-
- for(i=0; i<degB; i++) {
- BNU_CHUNK_T* ptr;
- mulF(pTmp, pInvB, GFPX_IDX_ELEMENT(pB, i, termLen), pGroundGFE);
- ptr = GFPX_IDX_ELEMENT(pR, GFP_EXTDEGREE(pGFEx)-degB+i, termLen);
- subF(ptr, ptr, pTmp, pGroundGFE);
- }
-
- gfpxPolyDiv(pQ, pR, pR, pB, pGFEx);
-
- cpGFpElementCopy(GFPX_IDX_ELEMENT(pQ, GFP_EXTDEGREE(pGFEx)-degB, termLen), pInvB, termLen);
-
- cpGFpReleasePool(2, pGroundGFE);
- return pR;
- }
-}
-
-BNU_CHUNK_T* cpGFpxInv(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsModEngine* pGFEx)
-{
- if( GFP_IS_BASIC(pGFEx) )
- return cpGFpInv(pR, pA, pGFEx);
-
- if(0==degree(pA, pGFEx)) {
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- BNU_CHUNK_T* tmpR = cpGFpGetPool(1, pGroundGFE);
- //gres: temporary excluded: assert(NULL!=tmpR);
-
- cpGFpxInv(tmpR, pA, pGroundGFE);
-
- cpGFpElementCopyPadd(pR, GFP_FELEN(pGFEx), tmpR, GFP_FELEN(pGroundGFE));
- cpGFpReleasePool(1, pGroundGFE);
- return pR;
- }
-
- else {
- int elemLen = GFP_FELEN(pGFEx);
- gsModEngine* pGroundGFE = GFP_PARENT(pGFEx);
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
-
- int pxVars = 6;
- int pelemLen = GFP_PELEN(pGFEx);
- BNU_CHUNK_T* lastrem = cpGFpGetPool(pxVars, pGFEx);
- BNU_CHUNK_T* rem = lastrem + pelemLen;
- BNU_CHUNK_T* quo = rem + pelemLen;
- BNU_CHUNK_T* lastaux = quo + pelemLen;
- BNU_CHUNK_T* aux = lastaux + pelemLen;
- BNU_CHUNK_T* temp = aux + pelemLen;
- //gres: temporary excluded: assert(NULL!=lastrem);
-
- cpGFpElementCopy(lastrem, pA, elemLen);
- cpGFpElementCopyPadd(lastaux, elemLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
-
- gfpxGeneratorDiv(quo, rem, pA, pGFEx);
- cpGFpxNeg(aux, quo, pGFEx);
-
- while(degree(rem, pGFEx) > 0) {
- gfpxPolyDiv(quo, temp, lastrem, rem, pGFEx);
- SWAP_PTR(BNU_CHUNK_T, rem, lastrem); //
- SWAP_PTR(BNU_CHUNK_T, temp, rem);
-
- GFP_METHOD(pGFEx)->neg(quo, quo, pGFEx);
- GFP_METHOD(pGFEx)->mul(temp, quo, aux, pGFEx);
- GFP_METHOD(pGFEx)->add(temp, lastaux, temp, pGFEx);
- SWAP_PTR(BNU_CHUNK_T, aux, lastaux);
- SWAP_PTR(BNU_CHUNK_T, temp, aux);
- }
- if (GFP_IS_ZERO(rem, elemLen)) { /* gcd != 1 */
- cpGFpReleasePool(pxVars, pGFEx);
- return NULL;
- }
-
- {
- BNU_CHUNK_T* invRem = cpGFpGetPool(1, pGroundGFE);
- //gres: temporary excluded: assert(NULL!=invRem);
-
- cpGFpxInv(invRem, rem, pGroundGFE);
- cpGFpxMul_GFE(pR, aux, invRem, pGFEx);
-
- cpGFpReleasePool(1, pGroundGFE);
- }
-
- cpGFpReleasePool(pxVars, pGFEx);
-
- return pR;
- }
-}
-
-
-static int div_upper(int a, int d)
-{ return (a+d-1)/d; }
-
-static int getNumOperations(int bitsize, int w)
-{
- int n_overhead = (1<<w) -1;
- int n_ops = div_upper(bitsize, w) + n_overhead;
- return n_ops;
-}
-int cpGFpGetOptimalWinSize(int bitsize)
-{
- int w_opt = 1;
- int n_opt = getNumOperations(bitsize, w_opt);
- int w_trial;
- for(w_trial=w_opt+1; w_trial<=IPP_MAX_EXPONENT_NUM; w_trial++) {
- int n_trial = getNumOperations(bitsize, w_trial);
- if(n_trial>=n_opt) break;
- w_opt = w_trial;
- n_opt = n_trial;
- }
- return w_opt;
-}
-
-
-//#define _GRES_DBG_
-#if defined(_GRES_DBG_)
-#include <stdio.h>
-static void printBNU(const char* note, Ipp64u* pData, int len, int nt)
-{
- int n, k;
-
- if(note)
- printf("%s", note);
-
- for(n=0, k=0; n<len; n++) {
- Ipp64u x = pData[n];
- printf("%016I64x ", x);
- k++;
- if(k==nt) {
- printf("\n");
- k = 0;
- }
- }
- printf("\n");
-}
-#endif
-
-/* sscm version */
-BNU_CHUNK_T* cpGFpxExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE,
- gsModEngine* pGFEx, Ipp8u* pScratchBuffer)
-{
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
-
- /* remove leding zeros */
- FIX_BNU(pE, nsE);
-
- {
- mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul and sqr methods */
- mod_sqr sqrF = GFP_METHOD(pGFEx)->sqr;
-
- BNU_CHUNK_T* pScratchAligned; /* aligned scratch buffer */
- int nAllocation = 0; /* points from the pool */
-
- /* size of element */
- int elmLen = GFP_FELEN(pGFEx);
-
- /* exponent bitsize */
- int expBitSize = BITSIZE_BNU(pE, nsE);
- /* optimal size of window */
- int w = (NULL==pScratchBuffer)? 1 : cpGFpGetOptimalWinSize(expBitSize);
- /* number of table entries */
- int nPrecomputed = 1<<w;
-
- int poolElmLen = GFP_PELEN(pGFEx);
- BNU_CHUNK_T* pExpandedE = cpGFpGetPool(1, pGFEx);
- BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFEx);
- //gres: temporary excluded: assert(NULL!=pExpandedE && NULL!=pTmp);
-
- if(NULL==pScratchBuffer) {
- nAllocation = 2 + div_upper(CACHE_LINE_SIZE, poolElmLen*sizeof(BNU_CHUNK_T));
- pScratchBuffer = (Ipp8u*)cpGFpGetPool(nAllocation, pGFEx);
- //gres: temporary excluded: assert(NULL!=pScratchBuffer);
- }
- pScratchAligned = (BNU_CHUNK_T*)( IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE) );
-
- #if defined(_GRES_DBG_)
- printf("precom tbl:\n");
- #endif
- /* pre-compute auxiliary table t[] = {A^0, A^1, A^2, ..., A^(2^w-1)} */
- cpGFpElementCopyPadd(pTmp, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
- //cpScramblePut(pScratchAligned+0, nPrecomputed, (Ipp8u*)pTmp, elmDataSize);
- gsScramblePut(pScratchAligned, 0, pTmp, elmLen, w);
- #if defined(_GRES_DBG_)
- printBNU("precom tbl:\n", pTmp, 48, 6);
- #endif
-
- { /* pre compute multiplication table */
- int n;
- for(n=1; n<nPrecomputed; n++) {
- mulF(pTmp, pTmp, pA, pGFEx);
- //cpScramblePut(pScratchAligned+n, nPrecomputed, (Ipp8u*)pTmp, elmDataSize);
- gsScramblePut(pScratchAligned, n, pTmp, elmLen, w);
- #if defined(_GRES_DBG_)
- printBNU("precom tbl:\n", pTmp, 48, 6);
- #endif
- }
- }
-
- {
- /* copy exponent value */
- cpGFpElementCopy(pExpandedE, pE, nsE);
-
- /* expand exponent value */
- ((Ipp32u*)pExpandedE)[BITS2WORD32_SIZE(expBitSize)] = 0;
- expBitSize = ((expBitSize+w-1)/w)*w;
-
- #if defined(_GRES_DBG_)
- printf("\nexponentiation:\n");
- #endif
- /*
- // exponentiation
- */
- {
- /* digit mask */
- BNU_CHUNK_T dmask = nPrecomputed-1;
-
- /* position (bit number) of the leftmost window */
- int wPosition = expBitSize-w;
-
- /* extract leftmost window value */
- Ipp32u eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u)));
- int shift = wPosition & 0xF;
- Ipp32u windowVal = (eChunk>>shift) & dmask;
-
- /* initialize result */
- //cpScrambleGet((Ipp8u*)pR, elmDataSize, pScratchAligned+windowVal, nPrecomputed);
- gsScrambleGet_sscm(pR, elmLen, pScratchAligned, windowVal, w);
- #if defined(_GRES_DBG_)
- printBNU("init result:\n", pR, 48, 6);
- #endif
-
- for(wPosition-=w; wPosition>=0; wPosition-=w) {
- int k;
- #if defined(_GRES_DBG_)
- printf("\nwPosition=%d\n", wPosition);
- #endif
- /* w times squaring */
- for(k=0; k<w; k++) {
- sqrF(pR, pR, pGFEx);
- #if defined(_GRES_DBG_)
- printBNU("sqr:\n", pR, 48, 6);
- #endif
- }
-
- /* extract next window value */
- eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u)));
- shift = wPosition & 0xF;
- windowVal = (eChunk>>shift) & dmask;
-
- /* extract value from the pre-computed table */
- //cpScrambleGet((Ipp8u*)pTmp, elmDataSize, pScratchAligned+windowVal, nPrecomputed);
- gsScrambleGet_sscm(pTmp, elmLen, pScratchAligned, windowVal, w);
-
- /* and multiply */
- mulF(pR, pR, pTmp, pGFEx);
- #if defined(_GRES_DBG_)
- printBNU("mul:\n", pR, 48, 6);
- #endif
- }
- }
-
- }
-
- cpGFpReleasePool(nAllocation+2, pGFEx);
-
- return pR;
- }
-}
-
-static void cpPrecomputeMultiExp(BNU_CHUNK_T* pTable, const BNU_CHUNK_T* ppA[], int nItems, gsModEngine* pGFEx)
-{
- gsModEngine* pBasicGFE = cpGFpBasic(pGFEx);
-
- //int nPrecomputed = 1<<nItems;
-
- /* length of element (BNU_CHUNK_T) */
- int elmLen = GFP_FELEN(pGFEx);
-
- /* get resource */
- BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFEx);
- //gres: temporary excluded: assert(NULL!=pT);
-
- /* pTable[0] = 1 */
- cpGFpElementCopyPadd(pT, elmLen, GFP_MNT_R(pBasicGFE), GFP_FELEN(pBasicGFE));
- //cpScramblePut(pTable+0, nPrecomputed, (Ipp8u*)pT, elmDataSize);
- gsScramblePut(pTable, 0, pT, elmLen, nItems);
- /* pTable[1] = A[0] */
- //cpScramblePut(pTable+1, nPrecomputed, (Ipp8u*)(ppA[0]), elmDataSize);
- gsScramblePut(pTable, 1, ppA[0], elmLen, nItems);
-
- {
- mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul method */
-
- int i, baseIdx;
- for(i=1, baseIdx=2; i<nItems; i++, baseIdx*=2) {
- /* pTable[baseIdx] = A[i] */
- //cpScramblePut(pTable+baseIdx, nPrecomputed, (Ipp8u*)(ppA[i]), elmDataSize);
- gsScramblePut(pTable, baseIdx, ppA[i], elmLen, nItems);
-
- {
- int nPasses = 1;
- int step = baseIdx/2;
-
- int k;
- for(k=i-1; k>=0; k--) {
- int tblIdx = baseIdx;
-
- int n;
- for(n=0; n<nPasses; n++, tblIdx+=2*step) {
- /* use pre-computed value */
- //cpScrambleGet((Ipp8u*)pT, elmDataSize, pTable+tblIdx, nPrecomputed);
- gsScrambleGet(pT, elmLen, pTable, tblIdx, nItems);
- mulF(pT, pT, ppA[k], pGFEx);
- //cpScramblePut(pTable+tblIdx+step, nPrecomputed, (Ipp8u*)pT, elmDataSize);
- gsScramblePut(pTable, tblIdx+step, pT, elmLen, nItems);
- }
-
- nPasses *= 2;
- step /= 2;
- }
- }
- }
- }
-
- /* release resourse */
- cpGFpReleasePool(1, pGFEx);
-}
-
-static int cpGetMaxBitsizeExponent(const BNU_CHUNK_T* ppE[], int nsE[], int nItems)
-{
- int n;
- /* find out the longest exponent */
- int expBitSize = BITSIZE_BNU(ppE[0], nsE[0]);
- for(n=1; n<nItems; n++) {
- expBitSize = IPP_MAX(expBitSize, BITSIZE_BNU(ppE[n], nsE[n]));
- }
- return expBitSize;
-}
-
-static int GetIndex(const BNU_CHUNK_T* ppE[], int nItems, int nBit)
-{
- int shift = nBit%BYTESIZE;
- int offset= nBit/BYTESIZE;
- int index = 0;
-
- int n;
- for(n=nItems; n>0; n--) {
- const Ipp8u* pE = ((Ipp8u*)ppE[n-1]) + offset;
- Ipp8u e = pE[0];
- index <<= 1;
- index += (e>>shift) &1;
- }
- return index;
-}
-
-/* sscm version */
-BNU_CHUNK_T* cpGFpxMultiExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* ppA[], const BNU_CHUNK_T* ppE[], int nsE[], int nItems,
- gsModEngine* pGFEx, Ipp8u* pScratchBuffer)
-{
- /* align scratch buffer */
- BNU_CHUNK_T* pTable = (BNU_CHUNK_T*)( IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE) );
- /* pre-compute table */
- cpPrecomputeMultiExp(pTable, ppA, nItems, pGFEx);
-
- {
- mod_mul mulF = GFP_METHOD(pGFEx)->mul; /* mul and sqr methods and parameter */
- mod_sqr sqrF = GFP_METHOD(pGFEx)->sqr;
- int elmLen = GFP_FELEN(pGFEx);
-
- /* find out the longest exponent */
- int expBitSize = cpGetMaxBitsizeExponent(ppE, nsE, nItems);
-
- /* allocate resource and copy expanded exponents into */
- const BNU_CHUNK_T* ppExponent[IPP_MAX_EXPONENT_NUM];
- {
- int n;
- for(n=0; n<nItems; n++) {
- BNU_CHUNK_T* pData = cpGFpGetPool(1, pGFEx);
- //gres: temporary excluded: assert(NULL!=pData);
- cpGFpElementCopyPadd(pData, elmLen, ppE[n], nsE[n]);
- ppExponent[n] = pData;
- }
- }
-
- /* multiexponentiation */
- {
- /* get temporary */
- BNU_CHUNK_T* pT = cpGFpGetPool(1, pGFEx);
-
- /* init result */
- int tblIdx = GetIndex(ppExponent, nItems, --expBitSize);
- //cpScrambleGet((Ipp8u*)pR, elmDataSize, pScratchBuffer+tblIdx, nPrecomputed);
- gsScrambleGet_sscm(pR, elmLen, pTable, tblIdx, nItems);
-
- //gres: temporary excluded: assert(NULL!=pT);
-
- /* compute the rest: square and multiply */
- for(--expBitSize; expBitSize>=0; expBitSize--) {
- sqrF(pR, pR, pGFEx);
- tblIdx = GetIndex(ppExponent, nItems, expBitSize);
- //cpScrambleGet((Ipp8u*)pT, elmDataSize, pScratchBuffer+tblIdx, nPrecomputed);
- gsScrambleGet_sscm(pT, elmLen, pTable, tblIdx, nItems);
- mulF(pR, pR, pT, pGFEx);
- }
-
- /* release resourse */
- cpGFpReleasePool(1, pGFEx);
- }
-
- /* release resourse */
- cpGFpReleasePool(nItems, pGFEx);
-
- return pR;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcphash_rmf.h b/ext/ipp/sources/ippcp/src/pcphash_rmf.h
deleted file mode 100644
index 7a8a3a7..0000000
--- a/ext/ipp/sources/ippcp/src/pcphash_rmf.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Cryptography Primitive.
-// Security Hash Standard
-// Internal Definitions and Internal Functions Prototypes
-//
-*/
-
-#if !defined(_PCP_HASH_RMF_H)
-#define _PCP_HASH_RMF_H
-
-#include "pcphash.h"
-#include "pcphashmethod_rmf.h"
-
-
-struct _cpHashCtx_rmf {
- IppCtxId idCtx; /* hash identifier */
- const cpHashMethod_rmf* pMethod; /* hash methods */
- int msgBuffIdx; /* buffer index */
- Ipp8u msgBuffer[MBS_HASH_MAX]; /* buffer */
- Ipp64u msgLenLo; /* processed message */
- Ipp64u msgLenHi; /* length (bytes) */
- cpHash msgHash; /* hash value */
-};
-
-/* accessors */
-#define HASH_CTX_ID(stt) ((stt)->idCtx)
-#define HASH_METHOD(stt) ((stt)->pMethod)
-#define HAHS_BUFFIDX(stt) ((stt)->msgBuffIdx)
-#define HASH_BUFF(stt) ((stt)->msgBuffer)
-#define HASH_LENLO(stt) ((stt)->msgLenLo)
-#define HASH_LENHI(stt) ((stt)->msgLenHi)
-#define HASH_VALUE(stt) ((stt)->msgHash)
-
-#endif /* __PCP_HASH_RMF_H */
diff --git a/ext/ipp/sources/ippcp/src/pcphashca.c b/ext/ipp/sources/ippcp/src/pcphashca.c
deleted file mode 100644
index 881abfa..0000000
--- a/ext/ipp/sources/ippcp/src/pcphashca.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Security Hash Standard
-// General Functionality
-//
-// Contents:
-// ippsHashGetSize()
-// ippsHashInit()
-// ippsHashPack()
-// ippsHashUnpack()
-// ippsHashDuplicate()
-// ippsHashUpdate()
-// ippsHashGetTag()
-// ippsHashFinal()
-// ippsHashMessage()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsHashGetSize
-//
-// Purpose: Returns size (bytes) of IppsHashState state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to state size
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetSize,(int* pSize))
-{
- /* test pointers */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsHashState);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashInit
-//
-// Purpose: Init Hash state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer to the Hash state
-// algID hash alg ID
-//
-*F*/
-int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID)
-{
- int hashIvSize = cpHashIvSize(algID);
- const Ipp8u* iv = cpHashIV[algID];
-
- HASH_LENLO(pCtx) = CONST_64(0);
- HASH_LENHI(pCtx) = CONST_64(0);
- HAHS_BUFFIDX(pCtx) = 0;
- CopyBlock(iv, HASH_VALUE(pCtx), hashIvSize);
-
- return hashIvSize;
-}
-
-/*
-// hash alg default processing functions and opt argument
-*/
-static cpHashProc cpHashProcFunc[] = {
- (cpHashProc)NULL,
-
- #if defined(_ENABLE_ALG_SHA1_)
- #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
- UpdateSHA1ni,
- #else
- UpdateSHA1,
- #endif
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA256_)
- #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
- UpdateSHA256ni,
- #else
- UpdateSHA256,
- #endif
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA224_)
- #if(_SHA_NI_ENABLING_==_FEATURE_ON_)
- UpdateSHA256ni,
- #else
- UpdateSHA256,
- #endif
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA512_)
- UpdateSHA512,
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA384_)
- UpdateSHA512,
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_MD5_)
- UpdateMD5,
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SM3_)
- UpdateSM3,
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA512_224_)
- UpdateSHA512,
- #else
- NULL,
- #endif
-
- #if defined(_ENABLE_ALG_SHA512_256_)
- UpdateSHA512,
- #else
- NULL,
- #endif
-};
-
-#define cpInitHash OWNAPI(cpInitHash)
-int cpInitHash(IppsHashState* pCtx, IppHashAlgId algID)
-{
- /* setup default processing function */
- HASH_FUNC(pCtx) = cpHashProcFunc[algID];
-
- /* update default processing function if SHA-NI enabled */
- #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8)
- if( IsFeatureEnabled(SHA_NI_ENABLED) ) {
-
- #if defined(_ENABLE_ALG_SHA1_)
- if(ippHashAlg_SHA1==algID)
- HASH_FUNC(pCtx) = UpdateSHA1ni;
- #endif
-
- #if defined(_ENABLE_ALG_SHA256_) || defined(_ENABLE_ALG_SHA224_)
- if(ippHashAlg_SHA256==algID || ippHashAlg_SHA224==algID)
- HASH_FUNC(pCtx) = UpdateSHA256ni;
- #endif
- }
- #endif
-
- /* setup optional agr of processing function */
- HASH_FUNC_PAR(pCtx) = cpHashProcFuncOpt[algID];
-
- return cpReInitHash(pCtx, algID);
-}
-
-IPPFUN(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId algID))
-{
- /* get algorithm id */
- algID = cpValidHashAlg(algID);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr);
-
- /* test ctx pointer */
- IPP_BAD_PTR1_RET(pCtx);
- /* test hash alg */
-
- /* set ctx ID */
- HASH_CTX_ID(pCtx) = idCtxHash;
- HASH_ALG_ID(pCtx) = algID;
-
- /* init context */
- cpInitHash(pCtx, algID);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashPack
-//
-// Purpose: Copy initialized context to the buffer.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// pBuffer == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsNoMemErr bufSize < sizeof(IppsHashState)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer hash state
-// pBuffer pointer to the destination buffer
-// bufSize size of the destination buffer
-//
-*F*/
-IPPFUN(IppStatus, ippsHashPack,(const IppsHashState* pCtx, Ipp8u* pBuffer, int bufSize))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
- /* test buffer length */
- IPP_BADARG_RET((int)(sizeof(IppsHashState))>bufSize, ippStsNoMemErr);
-
- CopyBlock(pCtx, pBuffer, sizeof(IppsHashState));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashUnpack
-//
-// Purpose: Unpack buffer content into the initialized context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// pBuffer == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBuffer pointer to the source buffer
-// pCtx pointer hash state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashUnpack,(const Ipp8u* pBuffer, IppsHashState* pCtx))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
-
- CopyBlock(pBuffer, pCtx, sizeof(IppsHashState));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashDuplicate
-//
-// Purpose: Clone Hash context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrcCtx == NULL
-// pDstCtx == NULL
-// ippStsContextMatchErr pSrcCtx->idCtx != idCtxHash
-// pDstCtx->idCtx != idCtxHash
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrcCtx pointer to the source Hash context
-// pDstCtx pointer to the target Hash context
-//
-// Note:
-// pDstCtx may to be uninitialized by ippsHashInit()
-//
-*F*/
-IPPFUN(IppStatus, ippsHashDuplicate,(const IppsHashState* pSrcCtx, IppsHashState* pDstCtx))
-{
- /* test state pointers */
- IPP_BAD_PTR2_RET(pSrcCtx, pDstCtx);
- /* test states ID */
- IPP_BADARG_RET(!HASH_VALID_ID(pSrcCtx), ippStsContextMatchErr);
-
- /* copy state */
- CopyBlock(pSrcCtx, pDstCtx, sizeof(IppsHashState));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashUpdate
-//
-// Purpose: Updates intermediate hash value based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// ippStsNullPtrErr pSrc==0 but len!=0
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pCtx pointer to the Hash context
-//
-*F*/
-__INLINE int IsExceedMsgLen(Ipp64u maxLo, Ipp64u maxHi, Ipp64u lenLo, Ipp64u lenHi)
-{
- int isExceed = lenLo > maxLo;
- isExceed = (lenHi+isExceed) > maxHi;
- return isExceed;
-}
-
-IPPFUN(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
- /* test input length */
- IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- /* handle non empty input */
- if(len) {
- const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)];
-
- /* test if size of message is being processed not exceeded yet */
- Ipp64u lenLo = HASH_LENLO(pCtx);
- Ipp64u lenHi = HASH_LENHI(pCtx);
- lenLo += len;
- if(lenLo < HASH_LENLO(pCtx)) lenHi++;
- if(IsExceedMsgLen(pAttr->msgLenMax[0],pAttr->msgLenMax[1], lenLo,lenHi))
- IPP_ERROR_RET(ippStsLengthErr);
-
- else {
- cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */
- const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */
- int mbs = pAttr->msgBlkSize; /* data block size */
-
- /*
- // processing
- */
- {
- int procLen;
-
- /* test if internal buffer is not empty */
- int n = HAHS_BUFFIDX(pCtx);
- if(n) {
- procLen = IPP_MIN(len, (mbs-n));
- CopyBlock(pSrc, HASH_BUFF(pCtx)+n, procLen);
- HAHS_BUFFIDX(pCtx) = n += procLen;
-
- /* block processing */
- if(mbs==n) {
- hashFunc(HASH_VALUE(pCtx), HASH_BUFF(pCtx), mbs, pParam);
- HAHS_BUFFIDX(pCtx) = 0;
- }
-
- /* update message pointer and length */
- pSrc += procLen;
- len -= procLen;
- }
-
- /* main processing part */
- procLen = len & ~(mbs-1);
- if(procLen) {
- hashFunc(HASH_VALUE(pCtx), pSrc, procLen, pParam);
- pSrc += procLen;
- len -= procLen;
- }
-
- /* rest of input message */
- if(len) {
- CopyBlock(pSrc, HASH_BUFF(pCtx), len);
- HAHS_BUFFIDX(pCtx) += len;
- }
- }
-
- /* update length of processed message */
- HASH_LENLO(pCtx) = lenLo;
- HASH_LENHI(pCtx) = lenHi;
-
- return ippStsNoErr;
- }
- }
-
- return ippStsNoErr;
-}
-
-static void cpComputeDigest(Ipp8u* pHashTag, int hashTagLen, const IppsHashState* pCtx)
-{
- /* hash alg and parameters */
- cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */
- const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */
-
- /* attributes */
- const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)];
- int mbs = pAttr->msgBlkSize; /* data block size */
- int ivSize = pAttr->ivSize; /* size of hash's IV */
- int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
-
- /* number of bytes in context buffer */
- int n = HAHS_BUFFIDX(pCtx);
- /* buffer and it actual length */
- Ipp8u buffer[MBS_HASH_MAX*2];
- int bufferLen = n < (mbs-msgLenRepSize)? mbs : mbs*2;
-
- /* copy current hash value */
- cpHash hash;
- CopyBlock(HASH_VALUE(pCtx), hash, ivSize);
-
- /* copy of state's buffer */
- CopyBlock(HASH_BUFF(pCtx), buffer, n);
- /* end of message bit */
- buffer[n++] = 0x80;
- /* padd buffer */
- PaddBlock(0, buffer+n, bufferLen-n-msgLenRepSize);
-
- /* message length representation in bits (remember about big endian) */
- {
- /* convert processed message length bytes ->bits */
- Ipp64u lo = HASH_LENLO(pCtx);
- Ipp64u hi = HASH_LENHI(pCtx);
- hi = LSL64(hi,3) | LSR64(lo,63-3);
- lo = LSL64(lo,3);
-
- if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-2] = hi;
- #else
- ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(hi);
- #endif
- }
-
- /* recall about MD5 specific */
- if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
- #else
- ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
- #endif
- }
- else {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
- #else
- ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
- #endif
- }
- }
-
- /* copmplete hash computation */
- hashFunc(hash, buffer, bufferLen, pParam);
-
- /* store digest into the user buffer (remember digest in big endian) */
- if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
- /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
- hash[0] = ENDIANNESS64(hash[0]);
- hash[1] = ENDIANNESS64(hash[1]);
- hash[2] = ENDIANNESS64(hash[2]);
- hash[3] = ENDIANNESS64(hash[3]);
- hash[4] = ENDIANNESS64(hash[4]);
- hash[5] = ENDIANNESS64(hash[5]);
- hash[6] = ENDIANNESS64(hash[6]);
- hash[7] = ENDIANNESS64(hash[7]);
- }
- else if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
- ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
- ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
- ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
- ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
- ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
- if(ippHashAlg_SHA1!=HASH_ALG_ID(pCtx)) {
- ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
- ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
- ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
- }
- }
- CopyBlock(hash, pHashTag, hashTagLen);
-}
-
-
-/*F*
-// Name: ippsHashGetTag
-//
-// Purpose: Compute digest based on current state.
-// Note, that futher digest update is possible
-//
-// Returns: Reason:
-// ippStsNullPtrErr pTag == NULL
-// pCtx == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr hashSize < tagLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pTag address of the output digest
-// tagLen length of digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetTag,(Ipp8u* pTag, int tagLen, const IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR2_RET(pTag, pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
-
- {
- /* size of hash */
- int hashSize = cpHashAlgAttr[HASH_ALG_ID(pCtx)].hashSize;
- if(tagLen<1||hashSize<tagLen) IPP_ERROR_RET(ippStsLengthErr);
-
- cpComputeDigest(pTag, tagLen, pCtx);
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsHashFinal
-//
-// Purpose: Complete message digesting and return digest.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pCtx == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR2_RET(pMD, pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
-
- {
- IppHashAlgId algID = HASH_ALG_ID(pCtx);
- int hashSize = cpHashAlgAttr[algID].hashSize;
-
- cpComputeDigest(pMD, hashSize, pCtx);
- cpReInitHash(pCtx, algID);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsHashMessage
-//
-// Purpose: Hash of the whole message.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pMsg == NULL but msgLen!=0
-// ippStsLengthErr msgLen <0
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the input message
-// msgLen input message length
-// pMD address of the output digest
-// algID hash alg ID
-//
-*F*/
-IPPFUN(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD, IppHashAlgId algID))
-{
- /* get algorithm id */
- algID = cpValidHashAlg(algID);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
- /* test message length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- /* test message pointer */
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- {
- /* processing function and parameter */
- cpHashProc hashFunc = cpHashProcFunc[algID];
- const void* pParam = cpHashProcFuncOpt[algID];
-
- /* attributes */
- const cpHashAttr* pAttr = &cpHashAlgAttr[algID];
- int mbs = pAttr->msgBlkSize; /* data block size */
- int ivSize = pAttr->ivSize; /* size of hash's IV */
- int hashSize = pAttr->hashSize; /* hash size */
- int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
-
- /* message bitlength representation */
- Ipp64u msgLenBits = (Ipp64u)msgLen*8;
- /* length of main message part */
- int msgLenBlks = msgLen & (-mbs);
- /* rest of message length */
- int msgLenRest = msgLen - msgLenBlks;
-
- /* end of message buffer */
- Ipp8u buffer[MBS_HASH_MAX*2];
- int bufferLen = (msgLenRest < (mbs-msgLenRepSize))? mbs : mbs*2;
-
- /* init hash */
- cpHash hash;
- const Ipp8u* iv = cpHashIV[algID];
- CopyBlock(iv, hash, ivSize);
-
- /*construct last messge block(s) */
- #define MSG_LEN_REP (sizeof(Ipp64u))
-
- /* copy end of message */
- CopyBlock(pMsg+msgLen-msgLenRest, buffer, msgLenRest);
- /* end of message bit */
- buffer[msgLenRest++] = 0x80;
- /* padd buffer */
- PaddBlock(0, buffer+msgLenRest, bufferLen-msgLenRest-MSG_LEN_REP);
- /* copy message bitlength representation */
- if(ippHashAlg_MD5!=algID)
- msgLenBits = ENDIANNESS64(msgLenBits);
- ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits;
-
- #undef MSG_LEN_REP
-
- /* message processing */
- if(msgLenBlks)
- hashFunc(hash, pMsg, msgLenBlks, pParam);
- hashFunc(hash, buffer, bufferLen, pParam);
-
- /* store digest into the user buffer (remember digest in big endian) */
- if(msgLenRepSize > (int)(sizeof(Ipp64u))) {
- /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
- hash[0] = ENDIANNESS64(hash[0]);
- hash[1] = ENDIANNESS64(hash[1]);
- hash[2] = ENDIANNESS64(hash[2]);
- hash[3] = ENDIANNESS64(hash[3]);
- hash[4] = ENDIANNESS64(hash[4]);
- hash[5] = ENDIANNESS64(hash[5]);
- hash[6] = ENDIANNESS64(hash[6]);
- hash[7] = ENDIANNESS64(hash[7]);
- }
- else if(ippHashAlg_MD5!=algID) {
- /* ippHashAlg_SHA1, ippHashAlg_SHA224, ippHashAlg_SHA256 and ippHashAlg_SM3 */
- ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
- ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
- ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
- ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
- ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
- ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
- ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
- ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
- }
- CopyBlock(hash, pMD, hashSize);
-
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcphashca_rmf.c b/ext/ipp/sources/ippcp/src/pcphashca_rmf.c
deleted file mode 100644
index b395fcb..0000000
--- a/ext/ipp/sources/ippcp/src/pcphashca_rmf.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Security Hash Standard
-// Generalized Functionality
-//
-// Contents:
-// ippsHashGetSize_rmf()
-// ippsHashInit_rmf()
-// ippsHashPack_rmf()
-// ippsHashUnpack_rmf()
-// ippsHashDuplicate_rmf()
-// ippsHashUpdate_rmf()
-// ippsHashGetTag_rmf()
-// ippsHashFinal_rmf()
-// ippsHashMessage_rmf()
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcphash_rmf.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsHashGetSize_rmf
-//
-// Purpose: Returns size (bytes) of IppsHashState state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to state size
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetSize_rmf,(int* pSize))
-{
- /* test pointers */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsHashState_rmf) +(HASH_ALIGNMENT-1);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashInit_rmf
-//
-// Purpose: Init Hash state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// pMethod == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer to the Hash state
-// pMethod hash method
-//
-*F*/
-IPPFUN(IppStatus, ippsHashInit_rmf,(IppsHashState_rmf* pCtx, const IppsHashMethod* pMethod))
-{
- /* test ctx pointers */
- IPP_BAD_PTR2_RET(pCtx, pMethod);
- pCtx= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pCtx, HASH_ALIGNMENT) );
-
- PaddBlock(0, pCtx, sizeof(IppsHashState_rmf));
- HASH_METHOD(pCtx) = pMethod;
- HASH_CTX_ID(pCtx) = idCtxHash;
- pMethod->hashInit(HASH_VALUE(pCtx));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashPack_rmf
-//
-// Purpose: Copy initialized context to the buffer.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// pBuffer == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsNoMemErr bufSize < sizeof(IppsHashState_rmf)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer hash state
-// pBuffer pointer to the destination buffer
-// bufSize size of the destination buffer
-//
-*F*/
-IPPFUN(IppStatus, ippsHashPack_rmf,(const IppsHashState_rmf* pCtx, Ipp8u* pBuffer, int bufSize))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
- pCtx= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pCtx, HASH_ALIGNMENT) );
- IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pCtx), ippStsContextMatchErr);
- /* test buffer length */
- IPP_BADARG_RET((int)(sizeof(IppsHashState_rmf)+HASH_ALIGNMENT-1)>bufSize, ippStsNoMemErr);
-
- CopyBlock(pCtx, pBuffer, sizeof(IppsHashState_rmf));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashUnpack_rmf
-//
-// Purpose: Unpack buffer content into the initialized context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBuffer == NULL
-// pCtx == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBuffer pointer to the source buffer
-// pCtx pointer hash state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashUnpack_rmf,(const Ipp8u* pBuffer, IppsHashState_rmf* pCtx))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
-
- CopyBlock(pBuffer, pCtx, sizeof(IppsHashState_rmf));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashDuplicate_rmf
-//
-// Purpose: Clone Hash context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrcCtx == NULL
-// pDstCtx == NULL
-// ippStsContextMatchErr pSrcCtx->idCtx != idCtxHash
-// pDstCtx->idCtx != idCtxHash
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrcCtx pointer to the source Hash context
-// pDstCtx pointer to the target Hash context
-//
-// Note:
-// pDstCtx may to be uninitialized by ippsHashInit_rmf()
-//
-*F*/
-IPPFUN(IppStatus, ippsHashDuplicate_rmf,(const IppsHashState_rmf* pSrcCtx, IppsHashState_rmf* pDstCtx))
-{
- /* test state pointers */
- IPP_BAD_PTR2_RET(pSrcCtx, pDstCtx);
- pSrcCtx = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pSrcCtx, HASH_ALIGNMENT) );
- pDstCtx = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pDstCtx, HASH_ALIGNMENT) );
- /* test states ID */
- IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pSrcCtx), ippStsContextMatchErr);
-
- /* copy state */
- CopyBlock(pSrcCtx, pDstCtx, sizeof(IppsHashState_rmf));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashUpdate_rmf
-//
-// Purpose: Updates intermediate hash value based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// ippStsNullPtrErr pSrc==0 but len!=0
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pCtx pointer to the Hash context
-//
-*F*/
-IPPFUN(IppStatus, ippsHashUpdate_rmf,(const Ipp8u* pSrc, int len, IppsHashState_rmf* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- pCtx= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pCtx, HASH_ALIGNMENT) );
- IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pCtx), ippStsContextMatchErr);
-
- /* test input length */
- IPP_BADARG_RET((len<0), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- if(len) {
- const IppsHashMethod* method = HASH_METHOD(pCtx);
- hashUpdateF hashFunc = method->hashUpdate; /* processing function */
- int msgBlkSize = method->msgBlkSize; /* messge block size */
-
- int procLen;
-
- int idx = HAHS_BUFFIDX(pCtx);
- Ipp64u lenLo = HASH_LENLO(pCtx);
- Ipp64u lenHi = HASH_LENHI(pCtx);
- lenLo += len;
- if(lenLo < HASH_LENLO(pCtx)) lenHi++;
-
- /* if internal buffer is not empty */
- if(idx) {
- procLen = IPP_MIN(len, (msgBlkSize-idx));
- CopyBlock(pSrc, HASH_BUFF(pCtx)+idx, procLen);
- idx += procLen;
-
- /* process complete message block */
- if(msgBlkSize==idx) {
- hashFunc(HASH_VALUE(pCtx), HASH_BUFF(pCtx), msgBlkSize);
- idx = 0;
- }
-
- /* update message pointer and length */
- pSrc += procLen;
- len -= procLen;
- }
-
- /* process main part of the input*/
- procLen = len & ~(msgBlkSize-1);
- if(procLen) {
- hashFunc(HASH_VALUE(pCtx), pSrc, procLen);
- pSrc += procLen;
- len -= procLen;
- }
-
- /* store the rest of input in the buffer */
- if(len) {
- CopyBlock(pSrc, HASH_BUFF(pCtx), len);
- idx += len;
- }
-
- /* update length of processed message */
- HASH_LENLO(pCtx) = lenLo;
- HASH_LENHI(pCtx) = lenHi;
- HAHS_BUFFIDX(pCtx) = idx;
- }
-
- return ippStsNoErr;
-}
-
-
-static void cpFinalize_rmf(DigestSHA512 pHash,
- const Ipp8u* inpBuffer, int inpLen,
- Ipp64u lenLo, Ipp64u lenHi,
- const IppsHashMethod* method)
-{
- int mbs = method->msgBlkSize; /* messge block size */
- int mrl = method->msgLenRepSize; /* processed length representation size */
-
- /* local buffer and it length */
- Ipp8u buffer[MBS_SHA512*2];
- int bufferLen = inpLen < (mbs-mrl)? mbs : mbs*2;
-
- /* copy rest of message into internal buffer */
- CopyBlock(inpBuffer, buffer, inpLen);
-
- /* padd message */
- buffer[inpLen++] = 0x80;
- PaddBlock(0, buffer+inpLen, bufferLen-inpLen-mrl);
-
- /* message length representation */
- method->msgLenRep(buffer+bufferLen-mrl, lenLo, lenHi);
-
- /* copmplete hash computation */
- method->hashUpdate(pHash, buffer, bufferLen);
-}
-
-/*F*
-// Name: ippsHashFinal_rmf
-//
-// Purpose: Complete message digesting and return digest.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pCtx == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashFinal_rmf,(Ipp8u* pMD, IppsHashState_rmf* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR2_RET(pMD, pCtx);
- pCtx= (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pCtx, HASH_ALIGNMENT) );
- IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pCtx), ippStsContextMatchErr);
-
- {
- const IppsHashMethod* method = HASH_METHOD(pCtx);
-
- cpFinalize_rmf(HASH_VALUE(pCtx),
- HASH_BUFF(pCtx), HAHS_BUFFIDX(pCtx),
- HASH_LENLO(pCtx), HASH_LENHI(pCtx),
- method);
- /* convert hash into oct string */
- method->hashOctStr(pMD, HASH_VALUE(pCtx));
-
- /* re-init hash value */
- HAHS_BUFFIDX(pCtx) = 0;
- HASH_LENLO(pCtx) = 0;
- HASH_LENHI(pCtx) = 0;
- method->hashInit(HASH_VALUE(pCtx));
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsHashGetTag_rmf
-//
-// Purpose: Compute digest based on current state.
-// Note, that futher digest update is possible
-//
-// Returns: Reason:
-// ippStsNullPtrErr pTag == NULL
-// pCtx == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr hashSize < tagLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pTag address of the output digest
-// tagLen length of digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetTag_rmf,(Ipp8u* pTag, int tagLen, const IppsHashState_rmf* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- pCtx = (IppsHashState_rmf*)( IPP_ALIGNED_PTR(pCtx, HASH_ALIGNMENT) );
- IPP_BADARG_RET(idCtxHash !=HASH_CTX_ID(pCtx), ippStsContextMatchErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pTag);
- IPP_BADARG_RET((tagLen <1) || HASH_METHOD(pCtx)->hashLen<tagLen, ippStsLengthErr);
-
- { /* TBD: consider implementation without copy of internal buffer content */
- DigestSHA512 hash;
- const IppsHashMethod* method = HASH_METHOD(pCtx);
- CopyBlock(HASH_VALUE(pCtx), hash, sizeof(DigestSHA512));
- cpFinalize_rmf(hash,
- HASH_BUFF(pCtx), HAHS_BUFFIDX(pCtx),
- HASH_LENLO(pCtx), HASH_LENHI(pCtx),
- method);
- method->hashOctStr(pTag, hash);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsHashMessage_rmf
-//
-// Purpose: Hash of the whole message.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pMsg == NULL but msgLen!=0
-// ippStsLengthErr msgLen <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the input message
-// msgLen input message length
-// pMD address of the output digest
-// pMethod hash methods
-//
-*F*/
-IPPFUN(IppStatus, ippsHashMessage_rmf,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD, const IppsHashMethod* pMethod))
-{
- /* test method pointer */
- IPP_BAD_PTR1_RET(pMethod);
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
- /* test message length */
- IPP_BADARG_RET(0>msgLen, ippStsLengthErr);
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- {
- /* message length in the multiple MBS and the rest */
- int msgLenBlks = msgLen &(-pMethod->msgBlkSize);
- int msgLenRest = msgLen - msgLenBlks;
-
- /* init hash */
- DigestSHA512 hash;
- pMethod->hashInit(hash);
-
- /* process main part of the message */
- if(msgLenBlks) {
- pMethod->hashUpdate(hash, pMsg, msgLenBlks);
- pMsg += msgLenBlks;
- }
- cpFinalize_rmf(hash,
- pMsg, msgLenRest,
- msgLen, 0,
- pMethod);
-
- pMethod->hashOctStr(pMD, hash);
-
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcphashmethod_rmf.h b/ext/ipp/sources/ippcp/src/pcphashmethod_rmf.h
deleted file mode 100644
index 97a6e2a..0000000
--- a/ext/ipp/sources/ippcp/src/pcphashmethod_rmf.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Purpose:
-// Cryptography Primitive.
-// Security Hash Standard
-// Internal Definitions and Internal Functions Prototypes
-//
-*/
-#if !defined(_PCP_HASH_METHOD_RMF_H)
-#define _PCP_HASH_METHOD_RMF_H
-
-/* hash alg methods */
-typedef void (*hashInitF)(void* pHash);
-typedef void (*hashUpdateF)(void* pHash, const Ipp8u* pMsg, int msgLen);
-typedef void (*hashOctStrF)(Ipp8u* pDst, void* pHash);
-typedef void (*msgLenRepF)(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi);
-
-typedef struct _cpHashMethod_rmf {
- IppHashAlgId hashAlgId; /* algorithm ID */
- int hashLen; /* hash length in bytes */
- int msgBlkSize; /* message blkock size in bytes */
- int msgLenRepSize; /* length of processed msg length representation in bytes */
- hashInitF hashInit; /* set initial hash value */
- hashUpdateF hashUpdate; /* hash compressor */
- hashOctStrF hashOctStr; /* convert hash into oct string */
- msgLenRepF msgLenRep; /* processed mgs length representation */
-} cpHashMethod_rmf;
-
-#endif /* _PCP_HASH_METHOD_RMF_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c b/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c
deleted file mode 100644
index e22ae7e..0000000
--- a/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives (ippcp)
-//
-// Contents:
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-#include "pcpmulbnukara.h"
-#include "pcptool.h"
-
-//gres: temporary excluded: #include <assert.h>
-
-/* Auxilirary function */
-__INLINE int cpGetBitSize(Ipp32u offset, Ipp32u val)
-{
- int bitSize = 32;
- if (val == 0) return 0;
- while ((val & (1 << bitSize)) == 0) bitSize--;
- return offset + bitSize;
-}
-
-IppStatus cpMontGetSize(cpSize maxLen32, int poolLength, cpSize* pCtxSize)
-{
- {
- int size = 0;
- int maxBitSize = maxLen32 << 5;
- gsModEngineGetSize(maxBitSize, poolLength, &size);
-
- *pCtxSize = sizeof(IppsMontState)
- + (cpSize)size
- + MONT_ALIGNMENT-1;
-
- return ippStsNoErr;
- }
-}
-
-
-IppStatus cpMontInit(int maxLen32, int poolLength, IppsMontState* pMont)
-{
- pMont = (IppsMontState*)( IPP_ALIGNED_PTR(pMont, MONT_ALIGNMENT) );
- {
- int maxBitSize = ((maxLen32) << 5);
-
- MNT_ROOM( pMont ) = INTERNAL_BNU_LENGTH(maxLen32);
- MNT_ENGINE ( pMont ) = (gsModEngine*)((Ipp8u*)pMont + sizeof(IppsMontState));
-
- MNT_ID(pMont) = idCtxMontgomery;
-
- gsModEngineInit(MNT_ENGINE(pMont), NULL, maxBitSize, poolLength, gsModArithMont());
-
- return ippStsNoErr;
- }
-}
-
-IppStatus cpMontSet(const Ipp32u* pModulus, cpSize len32, IppsMontState* pMont)
-{
- IPP_BADARG_RET(len32<1, ippStsLengthErr);
-
- /* modulus is not an odd number */
- IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr);
- IPP_BADARG_RET(MNT_ROOM(pMont)<(int)(INTERNAL_BNU_LENGTH(len32)), ippStsOutOfRangeErr);
-
- {
- const int poolLen = MOD_MAXPOOL(MNT_ENGINE(pMont));
- int modulusBitSize = cpGetBitSize((len32 - 1) << 5, pModulus[len32-1]);
-
- gsModEngineInit(MNT_ENGINE(pMont), pModulus, modulusBitSize, poolLen, gsModArithMont());
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsMontGetSize
-//
-// Purpose: Specifies size of buffer in bytes.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtxSize==NULL
-// ippStsLengthErr maxLen32 < 1
-// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// method selected exponential method (unused parameter)
-// maxLen32 max modulus length (in Ipp32u chunks)
-// pCtxSize size of context
-//
-// Notes: Function always use method=ippBinaryMethod,
-// so this parameter is ignored
-*F*/
-IPPFUN(IppStatus, ippsMontGetSize, (IppsExpMethod method, cpSize maxLen32, cpSize* pCtxSize))
-{
- IPP_BAD_PTR1_RET(pCtxSize);
- IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- UNREFERENCED_PARAMETER(method);
-
- {
- return cpMontGetSize(maxLen32, MONT_DEFAULT_POOL_LENGTH, pCtxSize);
- }
-}
-
-/*F*
-// Name: ippsMontInit
-//
-// Purpose: Initializes the symbolic data structure and partitions the
-// specified buffer space.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// ippStsLengthErr maxLen32 < 1
-// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// method selected exponential method (unused parameter)
-// maxLen32 max modulus length (in Ipp32u chunks)
-// pMont pointer to Montgomery context
-*F*/
-IPPFUN(IppStatus, ippsMontInit,(IppsExpMethod method, int maxLen32, IppsMontState* pMont))
-{
- IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- IPP_BAD_PTR1_RET(pMont);
-
- UNREFERENCED_PARAMETER(method);
-
- {
- return cpMontInit(maxLen32, MONT_DEFAULT_POOL_LENGTH, pMont);
- }
-}
-
-void cpPackMontCtx(const IppsMontState* pCtx, Ipp8u* pBuffer)
-{
- IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT));
-
- /* size of context (bytes) */
- int ctxSize = sizeof(IppsMontState);
- CopyBlock(pCtx, pAlignedBuffer, ctxSize);
-
- pBuffer = (Ipp8u*)pAlignedBuffer + sizeof(IppsMontState);
-
- gsPackModEngineCtx(MNT_ENGINE(pCtx), pBuffer);
-}
-
-void cpUnpackMontCtx(const Ipp8u* pBuffer, IppsMontState* pCtx)
-{
- IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT));
-
- /* size of context (bytes) */
- int ctxSize = sizeof(IppsMontState);
- CopyBlock(pAlignedBuffer, pCtx, ctxSize);
-
- pBuffer = (Ipp8u*)pAlignedBuffer + sizeof(IppsMontState);
-
- gsUnpackModEngineCtx(pBuffer, MNT_ENGINE(pCtx));
-}
-
-
-/*F*
-// Name: ippsMontSet
-//
-// Purpose: Setup modulus value
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// pModulus==NULL
-// ippStsContextMatchErr !MNT_VALID_ID()
-// ippStsLengthErr len32<1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pModulus pointer to the modulus buffer
-// len32 length of the modulus (in Ipp32u chunks).
-// pMont pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsMontSet,(const Ipp32u* pModulus, cpSize len32, IppsMontState* pMont))
-{
- IPP_BAD_PTR2_RET(pModulus, pMont);
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
-
- IPP_BADARG_RET(len32<1, ippStsLengthErr);
-
- /* modulus is not an odd number */
- IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr);
- IPP_BADARG_RET(((Ipp32u)MNT_ROOM(pMont) < INTERNAL_BNU_LENGTH(len32)), ippStsOutOfRangeErr);
-
- {
- return cpMontSet(pModulus, len32, pMont);
- }
-}
-
-/*F*
-// Name: ippsMontGet
-//
-// Purpose: Extracts modulus.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// pModulus==NULL
-// pLen32==NULL
-// ippStsContextMatchErr !MNT_VALID_ID()
-// ippStsNoErr no errors
-//
-// Parameters:
-// pModulus pointer to the modulus buffer
-// pLen32 pointer to the modulus length (in Ipp32u chunks).
-// pMont pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsMontGet,(Ipp32u* pModulus, cpSize* pLen32, const IppsMontState* pMont))
-{
- IPP_BAD_PTR3_RET(pMont, pModulus, pLen32);
-
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
-
- {
- cpSize len32 = MOD_LEN(MNT_ENGINE(pMont))*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u);
- Ipp32u* bnData = (Ipp32u*) MOD_MODULUS( MNT_ENGINE(pMont) );
-
- FIX_BNU(bnData, len32);
- COPY_BNU(pModulus, bnData, len32);
- *pLen32 = len32;
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsMontForm
-//
-// Purpose: Converts input into Montgomery domain.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// pA==NULL
-// pR==NULL
-// ippStsContextMatchErr !MNT_VALID_ID()
-// !BN_VALID_ID(pA)
-// !BN_VALID_ID(pR)
-// ippStsBadArgErr A < 0.
-// ippStsScaleRangeErr A >= Modulus.
-// ippStsOutOfRangeErr R can't hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA pointer to the input [0, modulus-1]
-// pMont Montgomery context
-// pR pointer to the output (A*R mod modulus)
-*F*/
-IPPFUN(IppStatus, ippsMontForm,(const IppsBigNumState* pA, IppsMontState* pMont, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pMont, pA, pR);
-
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
-
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_SIGN(pA) != ippBigNumPOS, ippStsBadArgErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pMont) ), MOD_LEN( MNT_ENGINE(pMont) )) >= 0, ippStsScaleRangeErr);
- IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pMont) ), ippStsOutOfRangeErr);
-
- {
- const int usedPoolLen = 1;
- cpSize nsM = MOD_LEN( MNT_ENGINE(pMont) );
- BNU_CHUNK_T* pDataA = gsModPoolAlloc(MNT_ENGINE(pMont), usedPoolLen);
- //gres: temporary excluded: assert(NULL!=pDataA);
-
- ZEXPAND_COPY_BNU(pDataA, nsM, BN_NUMBER(pA), BN_SIZE(pA));
-
- MOD_METHOD( MNT_ENGINE(pMont) )->encode(BN_NUMBER(pR), pDataA, MNT_ENGINE(pMont));
-
- FIX_BNU(BN_NUMBER(pR), nsM);
- BN_SIZE(pR) = nsM;
- BN_SIGN(pR) = ippBigNumPOS;
-
- gsModPoolFree(MNT_ENGINE(pMont), usedPoolLen);
- }
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsMontMul
-//
-// Purpose: Computes Montgomery modular multiplication for positive big
-// number integers of Montgomery form. The following pseudocode
-// represents this function:
-// r <- ( a * b * R^(-1) ) mod m
-//
-// Returns: Reason:
-// ippStsNoErr Returns no error.
-// ippStsNullPtrErr Returns an error when pointers are null.
-// ippStsBadArgErr Returns an error when a or b is a negative integer.
-// ippStsScaleRangeErr Returns an error when a or b is more than m.
-// ippStsOutOfRangeErr Returns an error when IppsBigNumState *r is larger than
-// IppsMontState *m.
-// ippStsContextMatchErr Returns an error when the context parameter does
-// not match the operation.
-//
-// Parameters:
-// a Multiplicand within the range [0, m - 1].
-// b Multiplier within the range [0, m - 1].
-// m Modulus.
-// r Montgomery multiplication result.
-//
-// Notes: The size of IppsBigNumState *r should not be less than the data
-// length of the modulus m.
-*F*/
-IPPFUN(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* pMont, IppsBigNumState* pR))
-{
- IPP_BAD_PTR4_RET(pA, pB, pMont, pR);
-
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
-
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_NEGATIVE(pA) || BN_NEGATIVE(pB), ippStsBadArgErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pMont) ), MOD_LEN( MNT_ENGINE(pMont) )) >= 0, ippStsScaleRangeErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pB), BN_SIZE(pB), MOD_MODULUS( MNT_ENGINE(pMont) ), MOD_LEN( MNT_ENGINE(pMont) )) >= 0, ippStsScaleRangeErr);
- IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pMont) ), ippStsOutOfRangeErr);
-
- {
- const int usedPoolLen = 2;
- cpSize nsM = MOD_LEN( MNT_ENGINE(pMont) );
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
- BNU_CHUNK_T* pDataA = gsModPoolAlloc(MNT_ENGINE(pMont), usedPoolLen);
- BNU_CHUNK_T* pDataB = pDataA + nsM;
- //gres: temporary excluded: assert(NULL!=pDataA);
-
- ZEXPAND_COPY_BNU(pDataA, nsM, BN_NUMBER(pA), BN_SIZE(pA));
- ZEXPAND_COPY_BNU(pDataB, nsM, BN_NUMBER(pB), BN_SIZE(pB));
-
- MOD_METHOD( MNT_ENGINE(pMont) )->mul(pDataR, pDataA, pDataB, MNT_ENGINE(pMont));
-
- gsModPoolFree(MNT_ENGINE(pMont), usedPoolLen);
-
- FIX_BNU(pDataR, nsM);
- BN_SIZE(pR) = nsM;
- BN_SIGN(pR) = ippBigNumPOS;
-
- return ippStsNoErr;
- }
-}
-
-
-/*******************************************************************************
-// Name: ippsMontExp
-// Description: ippsMontExp() computes the Montgomery exponentiation with exponent
-// IppsBigNumState *e to the given big number integer of Montgomery form
-// IppsBigNumState *a with respect to the modulus IppsMontState *m.
-// Input Arguments: a - big number integer of Montgomery form within the
-// range [0,m-1]
-// e - big number exponent
-// m - Montgomery modulus of IppsMontState.
-// Output Arguments: r - the Montgomery exponentiation result.
-// Returns: IPPC_STATUS_OK - No Error
-// IPPC_STATUS_MONT_BAD_MODULUS - If a>m or b>m or m>R or P_MONT *m has
-// not been initialized by the primitive
-// function ippsMontInit( ).
-// IPPC_STATUS_BAD_ARG - Bad Arguments
-// Notes: IppsBigNumState *r should possess enough memory space as to hold the result
-// of the operation. i.e. both pointers r->d and r->buffer should possess
-// no less than (m->n->length) number of 32-bit words.
-*******************************************************************************/
-IPPFUN(IppStatus, ippsMontExp, (const IppsBigNumState* pA, const IppsBigNumState* pE, IppsMontState* pMont, IppsBigNumState* pR))
-{
- IPP_BAD_PTR4_RET(pA, pE, pMont, pR);
-
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, BN_ALIGNMENT) );
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
-
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pE), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_ROOM(pR) < MOD_LEN( MNT_ENGINE(pMont) ), ippStsOutOfRangeErr);
- /* check a */
- IPP_BADARG_RET(BN_NEGATIVE(pA), ippStsBadArgErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MOD_MODULUS( MNT_ENGINE(pMont) ), MOD_LEN( MNT_ENGINE(pMont) )) >= 0, ippStsScaleRangeErr);
- /* check e */
- IPP_BADARG_RET(BN_NEGATIVE(pE), ippStsBadArgErr);
-
- cpMontExpBin_BN(pR, pA, pE, MNT_ENGINE( pMont) );
-
- return ippStsNoErr;
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpmontred.c b/ext/ipp/sources/ippcp/src/pcpmontred.c
deleted file mode 100644
index c1fb05a..0000000
--- a/ext/ipp/sources/ippcp/src/pcpmontred.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives (ippcp)
-//
-*/
-
-#include "owncp.h"
-#include "pcpbnuarith.h"
-
-
-#if defined(_USE_C_cpMontRedAdc_BNU_)
-#pragma message ("C version of cpMontRedAdc_BNU: ON")
-#else
-//#pragma message ("C version of cpMontRedAdc_BNU: OFF")
-#endif
-
-#if !((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7) || \
- (_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP>=_IPP_G9) || \
- (_IPP==_IPP_S8) || \
- (_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E>=_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8)) || \
- defined(_USE_C_cpMontRedAdc_BNU_)
-#define cpMontRedAdc_BNU OWNAPI(cpMontRedAdc_BNU)
-void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
-{
- BNU_CHUNK_T carry;
- BNU_CHUNK_T extension;
-
- cpSize n;
- for(n=0, carry = 0; n<(nsM-1); n++) {
- BNU_CHUNK_T u = pProduct[n]*m0;
- BNU_CHUNK_T t = pProduct[nsM +n +1] + carry;
-
- extension = cpAddMulDgt_BNU(pProduct+n, pModulus, nsM, u);
- ADD_AB(carry, pProduct[nsM+n], pProduct[nsM+n], extension);
- t += carry;
-
- carry = t<pProduct[nsM+n+1];
- pProduct[nsM+n+1] = t;
- }
-
- m0 *= pProduct[nsM-1];
- extension = cpAddMulDgt_BNU(pProduct+nsM-1, pModulus, nsM, m0);
- ADD_AB(extension, pProduct[2*nsM-1], pProduct[2*nsM-1], extension);
-
- carry |= extension;
- carry -= cpSub_BNU(pR, pProduct+nsM, pModulus, nsM);
- /* condition copy: R = carry? Product+mSize : R */
- MASKED_COPY_BNU(pR, carry, pProduct+nsM, pR, nsM);
-}
-#endif
diff --git a/ext/ipp/sources/ippcp/src/pcpmontred.h b/ext/ipp/sources/ippcp/src/pcpmontred.h
deleted file mode 100644
index 21d1057..0000000
--- a/ext/ipp/sources/ippcp/src/pcpmontred.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-// Intel(R) Integrated Performance Primitives
-// Cryptographic Primitives (ippcp)
-//
-*/
-#if !defined(_CP_MONTRED_H)
-#define _CP_MONTRED_H
-
-#include "owndefs.h"
-#include "owncp.h"
-
-#include "pcpbnuimpl.h"
-/*
-// Montgomery reduction
-*/
-#define cpMontRedAdc_BNU OWNAPI(cpMontRedAdc_BNU)
-void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0);
-
-#define cpMontRedAdx_BNU OWNAPI(cpMontRedAdx_BNU)
-void cpMontRedAdx_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0);
-
-__INLINE void cpMontRed_BNU_opt(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
-{
-#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_)
- cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0);
-#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_)
- IsFeatureEnabled(ADCOX_ENABLED)? cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0)
- : cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0);
-#else
- cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0);
-#endif
-}
-
-#endif /* _CP_MONTRED_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpmulbnukara.h b/ext/ipp/sources/ippcp/src/pcpmulbnukara.h
deleted file mode 100644
index 9e8c377..0000000
--- a/ext/ipp/sources/ippcp/src/pcpmulbnukara.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// BN Multiplication (Karatsuba method) Definitions & Function Prototypes
-//
-// Contents:
-// cpKaratsubaBufferSize()
-// cpMul_BNU_karatuba()
-// cpSqr_BNU_karatuba()
-// cpKAdd_BNU()
-// cpKSub_BNU()
-//
-//
-*/
-
-#if !defined(_KARATSUBA_MUL_)
-#define _KARATSUBA_MUL_
-
-#if defined(_USE_KARATSUBA_)
-
-#if((_IPP==_IPP_W7) || \
- (_IPP==_IPP_T7))
- #define CP_KARATSUBA_MUL_THRESHOLD 16
- #define CP_KARATSUBA_SQR_THRESHOLD 32
-#elif ((_IPP==_IPP_V8) || \
- (_IPP==_IPP_P8) || \
- (_IPP==_IPP_G9) || \
- (_IPP==_IPP_S8))
- #define CP_KARATSUBA_MUL_THRESHOLD 32
- #define CP_KARATSUBA_SQR_THRESHOLD 32
-#elif ((_IPP>=_IPP_H9))
- #define CP_KARATSUBA_MUL_THRESHOLD 32
- #define CP_KARATSUBA_SQR_THRESHOLD 32
-
-#elif ((_IPP32E==_IPP32E_M7) || \
- (_IPP32E==_IPP32E_U8) || \
- (_IPP32E==_IPP32E_Y8) || \
- (_IPP32E==_IPP32E_E9) || \
- (_IPP32E==_IPP32E_N8))
- #define CP_KARATSUBA_MUL_THRESHOLD 16
- #define CP_KARATSUBA_SQR_THRESHOLD 40
-#elif ((_IPP32E>=_IPP32E_L9))
- #define CP_KARATSUBA_MUL_THRESHOLD 20
- #define CP_KARATSUBA_SQR_THRESHOLD 48
-
-#else
- #define CP_KARATSUBA_MUL_THRESHOLD 12
- #define CP_KARATSUBA_SQR_THRESHOLD 16
-#endif
-
-
-#define cpKaratsubaBufferSize OWNAPI(cpKaratsubaBufferSize)
-cpSize cpKaratsubaBufferSize(cpSize len);
-
-#define cpMul_BNU_karatsuba OWNAPI(cpMul_BNU_karatsuba)
-BNU_CHUNK_T cpMul_BNU_karatsuba(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY, cpSize ns,
- BNU_CHUNK_T* pBuffer);
-#define cpSqr_BNU_karatsuba OWNAPI(cpSqr_BNU_karatsuba)
-BNU_CHUNK_T cpSqr_BNU_karatsuba(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pX, cpSize ns,
- BNU_CHUNK_T* pBuffer);
-
-
-#else
- #define CP_KARATSUBA_MUL_THRESHOLD 0
- #define CP_KARATSUBA_SQR_THRESHOLD 0
-#endif /* _USE_KARATSUBA_ */
-
-#endif /* _KARATSUBA_MUL_ */
diff --git a/ext/ipp/sources/ippcp/src/pcpprng.h b/ext/ipp/sources/ippcp/src/pcpprng.h
deleted file mode 100644
index 52620ad..0000000
--- a/ext/ipp/sources/ippcp/src/pcpprng.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Internal Definitions and
-// Internal Pseudo Random Generator Function Prototypes
-//
-*/
-
-#if !defined(_CP_PRNG_H)
-#define _CP_PRNG_H
-
-/*
-// Pseudo-random generation context
-*/
-
-#define MAX_XKEY_SIZE 512
-#define DEFAULT_XKEY_SIZE 512 /* must be >=160 || <=512 */
-
-struct _cpPRNG {
- IppCtxId idCtx; /* PRNG identifier */
- cpSize seedBits; /* secret seed-key bitsize */
- BNU_CHUNK_T Q[BITS_BNU_CHUNK(160)]; /* modulus */
- BNU_CHUNK_T T[BITS_BNU_CHUNK(160)]; /* parameter of SHA_G() funct */
- BNU_CHUNK_T xAug[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* optional entropy augment */
- BNU_CHUNK_T xKey[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* secret seed-key */
-};
-
-/* alignment */
-#define PRNG_ALIGNMENT ((int)(sizeof(void*)))
-
-#define RAND_ID(ctx) ((ctx)->idCtx)
-#define RAND_SEEDBITS(ctx) ((ctx)->seedBits)
-#define RAND_Q(ctx) ((ctx)->Q)
-#define RAND_T(ctx) ((ctx)->T)
-#define RAND_XAUGMENT(ctx) ((ctx)->xAug)
-#define RAND_XKEY(ctx) ((ctx)->xKey)
-
-#define RAND_VALID_ID(ctx) (RAND_ID((ctx))==idCtxPRNG)
-
-#define cpPRNGen OWNAPI(cpPRNGen)
-int cpPRNGen(Ipp32u* pBuffer, cpSize bitLen, IppsPRNGState* pCtx);
-
-#define cpPRNGenPattern OWNAPI(cpPRNGenPattern)
-int cpPRNGenPattern(BNU_CHUNK_T* pRand, int bitSize,
- BNU_CHUNK_T botPattern, BNU_CHUNK_T topPattern,
- IppBitSupplier rndFunc, void* pRndParam);
-
-#define cpPRNGenRange OWNAPI(cpPRNGenRange)
-int cpPRNGenRange(BNU_CHUNK_T* pRand,
- const BNU_CHUNK_T* pLo, cpSize loLen,
- const BNU_CHUNK_T* pHi, cpSize hiLen,
- IppBitSupplier rndFunc, void* pRndParam);
-
-#endif /* _CP_PRNG_H */
diff --git a/ext/ipp/sources/ippcp/src/pcpprngenca.c b/ext/ipp/sources/ippcp/src/pcpprngenca.c
deleted file mode 100644
index b8ace8a..0000000
--- a/ext/ipp/sources/ippcp/src/pcpprngenca.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// PRNG Functions
-//
-// Contents:
-// ippsPRNGen()
-// ippsPRNGen_BN()
-//
-//
-*/
-
-#include "owndefs.h"
-
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcphash.h"
-#include "pcpprng.h"
-#include "pcptool.h"
-
-/*
-// G() function based on SHA1
-//
-// Parameters:
-// T 160 bit parameter
-// pHexStr input hex string
-// hexStrLen size of hex string (Ipp8u segnments)
-// xBNU 160 bit BNU result
-//
-// Note 1:
-// must to be hexStrLen <= 64 (512 bits)
-*/
-static
-void SHA1_G(Ipp32u* xBNU, const Ipp32u* T, Ipp8u* pHexStr, int hexStrLen)
-{
- /* select processing function */
- cpHashProc updateFunc;
- #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
- updateFunc = UpdateSHA1ni;
- #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
- updateFunc = IsFeatureEnabled(SHA_NI_ENABLED)? UpdateSHA1ni : UpdateSHA1;
- #else
- updateFunc = UpdateSHA1;
- #endif
-
- /* pad HexString zeros */
- PaddBlock(0, pHexStr+hexStrLen, BITS2WORD8_SIZE(MAX_XKEY_SIZE)-hexStrLen);
-
- /* reset initial HASH value */
- xBNU[0] = T[0];
- xBNU[1] = T[1];
- xBNU[2] = T[2];
- xBNU[3] = T[3];
- xBNU[4] = T[4];
-
- /* SHA1 */
- //UpdateSHA1(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
- updateFunc(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
-
- /* swap back */
- SWAP(xBNU[0],xBNU[4]);
- SWAP(xBNU[1],xBNU[3]);
-}
-
-/*
-// Returns bitsize of the bitstring has beed added
-*/
-int cpPRNGen(Ipp32u* pRand, cpSize nBits, IppsPRNGState* pRnd)
-{
- BNU_CHUNK_T Xj [BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
- BNU_CHUNK_T XVAL[BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
-
- Ipp8u TXVAL[BITS2WORD8_SIZE(MAX_XKEY_SIZE)];
-
- /* XKEY length in BNU_CHUNK_T */
- cpSize xKeyLen = BITS_BNU_CHUNK(RAND_SEEDBITS(pRnd));
- /* XKEY length in bytes */
- cpSize xKeySize= BITS2WORD8_SIZE(RAND_SEEDBITS(pRnd));
- /* XKEY word's mask */
- BNU_CHUNK_T xKeyMsk = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd));
-
- /* number of Ipp32u chunks to be generated */
- cpSize genlen = BITS2WORD32_SIZE(nBits);
-
- ZEXPAND_BNU(Xj, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
- ZEXPAND_BNU(XVAL, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
-
- while(genlen) {
- cpSize len;
-
- /* Step 1: XVAL=(Xkey+Xseed) mod 2^b */
- BNU_CHUNK_T carry = cpAdd_BNU(XVAL, RAND_XKEY(pRnd), RAND_XAUGMENT(pRnd), xKeyLen);
- XVAL[xKeyLen-1] &= xKeyMsk;
-
- /* Step 2: xj=G(t, XVAL) mod Q */
- cpToOctStr_BNU(TXVAL, xKeySize, XVAL, xKeyLen);
- SHA1_G((Ipp32u*)Xj, (Ipp32u*)RAND_T(pRnd), TXVAL, xKeySize);
-
- {
- cpSize sizeXj = BITS_BNU_CHUNK(160);
- if(0 <= cpCmp_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd),BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE)) )
- sizeXj = cpMod_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd), BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE));
- FIX_BNU(Xj, sizeXj);
- ZEXPAND_BNU(Xj, sizeXj, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
- }
-
- /* Step 3: Xkey=(1+Xkey+Xj) mod 2^b */
- cpInc_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), xKeyLen, 1);
- carry = cpAdd_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), Xj, xKeyLen);
- RAND_XKEY(pRnd)[xKeyLen-1] &= xKeyMsk;
-
- /* fill out result */
- len = genlen<BITS2WORD32_SIZE(IPP_SHA1_DIGEST_BITSIZE)? genlen : BITS2WORD32_SIZE(IPP_SHA1_DIGEST_BITSIZE);
- COPY_BNU(pRand, (Ipp32u*)Xj, len);
-
- pRand += len;
- genlen -= len;
- }
-
- return nBits;
-}
-
-/* generates random string of specified bitSize length
-
- returns:
- 1 random bit string generated
- -1 detected internal error (ippStsNoErr != rndFunc())
-*/
-int cpPRNGenPattern(BNU_CHUNK_T* pRand, int bitSize,
- BNU_CHUNK_T botPattern, BNU_CHUNK_T topPattern,
- IppBitSupplier rndFunc, void* pRndParam)
-{
- BNU_CHUNK_T topMask = MASK_BNU_CHUNK(bitSize);
- cpSize randLen = BITS_BNU_CHUNK(bitSize);
-
- IppStatus sts = rndFunc((Ipp32u*)pRand, bitSize, pRndParam);
- if(ippStsNoErr!=sts) return -1;
-
- pRand[randLen-1] &= topMask;
- pRand[0] |= botPattern;
- pRand[randLen-1] |= topPattern;
- return 1;
-}
-
-/* generates random string of specified bitSize length
- within specified ragnge lo < r < Hi
-
- returns:
- 0 random bit string not generated
- 1 random bit string generated
- -1 detected internal error (ippStsNoErr != rndFunc())
-*/
-int cpPRNGenRange(BNU_CHUNK_T* pRand,
- const BNU_CHUNK_T* pLo, cpSize loLen,
- const BNU_CHUNK_T* pHi, cpSize hiLen,
- IppBitSupplier rndFunc, void* pRndParam)
-{
- int bitSize = BITSIZE_BNU(pHi,hiLen);
- BNU_CHUNK_T topMask = MASK_BNU_CHUNK(bitSize);
-
- #define MAX_COUNT (1000)
- int n;
- for(n=0; n<MAX_COUNT; n++) {
- cpSize randLen;
- IppStatus sts = rndFunc((Ipp32u*)pRand, bitSize, pRndParam);
- if(ippStsNoErr!=sts) return -1;
-
- pRand[hiLen-1] &= topMask;
- randLen = cpFix_BNU(pRand, hiLen);
- if((0 < cpCmp_BNU(pRand, randLen, pLo, loLen)) && (0 < cpCmp_BNU(pHi, hiLen, pRand, randLen)))
- return 1;
- }
- #undef MAX_COUNT
-
- return 0; /* no random matched to (Lo,Hi) */
-}
-
-
-/*F*
-// Name: ippsPRNGen
-//
-// Purpose: Generates a pseudorandom bit sequence of the specified nBits length.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pBuffer
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-//
-// ippStsLengthErr 1 > nBits
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pBuffer pointer to the buffer
-// nBits number of bits be requested
-// pRndCtx pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGen,(Ipp32u* pBuffer, cpSize nBits, void* pRnd))
-{
- IppsPRNGState* pRndCtx = (IppsPRNGState*)pRnd;
-
- /* test PRNG context */
- IPP_BAD_PTR2_RET(pBuffer, pRnd);
-
- pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRndCtx, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr);
-
- /* test sizes */
- IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
-
- {
- cpSize rndSize = BITS2WORD32_SIZE(nBits);
- Ipp32u rndMask = MAKEMASK32(nBits);
-
- cpPRNGen(pBuffer, nBits, pRndCtx);
- pBuffer[rndSize-1] &= rndMask;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsPRNGen_BN
-//
-// Purpose: Generates a pseudorandom big number of the specified nBits length.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pRandBN
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pRandBN->idCtx
-//
-// ippStsLengthErr 1 > nBits
-// nBits > BN_ROOM(pRandBN)
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pRandBN pointer to the BN random
-// nBits number of bits be requested
-// pRndCtx pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGen_BN,(IppsBigNumState* pRandBN, int nBits, void* pRnd))
-{
- IppsPRNGState* pRndCtx;
-
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr);
-
- /* test random BN */
- IPP_BAD_PTR1_RET(pRandBN);
- pRandBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRandBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pRandBN), ippStsContextMatchErr);
-
- /* test sizes */
- IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
- IPP_BADARG_RET(nBits> BN_ROOM(pRandBN)*BNU_CHUNK_BITS, ippStsLengthErr);
-
-
- {
- BNU_CHUNK_T* pRand = BN_NUMBER(pRandBN);
- cpSize rndSize = BITS_BNU_CHUNK(nBits);
- BNU_CHUNK_T rndMask = MASK_BNU_CHUNK(nBits);
-
- cpPRNGen((Ipp32u*)pRand, nBits, pRndCtx);
- pRand[rndSize-1] &= rndMask;
-
- FIX_BNU(pRand, rndSize);
- BN_SIZE(pRandBN) = rndSize;
- BN_SIGN(pRandBN) = ippBigNumPOS;
-
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpprnginitca.c b/ext/ipp/sources/ippcp/src/pcpprnginitca.c
deleted file mode 100644
index abf63cc..0000000
--- a/ext/ipp/sources/ippcp/src/pcpprnginitca.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// PRNG Functions
-//
-// Contents:
-// ippsPRNGGetSize()
-// ippsPRNGInit()
-//
-//
-*/
-
-#include "owndefs.h"
-
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpprng.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsPRNGGetSize
-//
-// Purpose: Returns size of PRNG context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pSize pointer to the size of internal context
-*F*/
-IPPFUN(IppStatus, ippsPRNGGetSize, (int* pSize))
-{
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsPRNGState)
- +PRNG_ALIGNMENT-1;
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsPRNGInit
-//
-// Purpose: Initializes PRNG context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-//
-// ippStsLengthErr seedBits < 1
-// seedBits < MAX_XKEY_SIZE
-// seedBits%8 !=0
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// seedBits seed bitsize
-// pRnd pointer to the context to be initialized
-*F*/
-IPPFUN(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
-
- /* test sizes */
- IPP_BADARG_RET((1>seedBits) || (seedBits>MAX_XKEY_SIZE) ||(seedBits&7), ippStsLengthErr);
-
- {
- int hashIvSize = cpHashIvSize(ippHashAlg_SHA1);
- const Ipp8u* iv = cpHashIV[ippHashAlg_SHA1];
-
- /* cleanup context */
- ZEXPAND_BNU((Ipp8u*)pRnd, 0, (cpSize)(sizeof(IppsPRNGState)));
-
- RAND_ID(pRnd) = idCtxPRNG;
- RAND_SEEDBITS(pRnd) = seedBits;
-
- /* default Q parameter */
- ((Ipp32u*)RAND_Q(pRnd))[0] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[1] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[2] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[3] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[4] = 0xFFFFFFFF;
-
- /* default T parameter */
- CopyBlock(iv, RAND_T(pRnd), hashIvSize);
-
- return ippStsNoErr;
- }
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpprngsetca.c b/ext/ipp/sources/ippcp/src/pcpprngsetca.c
deleted file mode 100644
index 9949aaa..0000000
--- a/ext/ipp/sources/ippcp/src/pcpprngsetca.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// PRNG Functions
-//
-// Contents:
-// ippsPRNGSetModulus()
-// ippsPRNGSetSeed()
-// ippsPRNGSetAugment()
-// ippsPRNGSetH0()
-//
-//
-*/
-
-#include "owndefs.h"
-
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpprng.h"
-
-
-/*F*
-// Name: ippsPRNGSetModulus
-//
-// Purpose: Sets 160-bit modulus Q.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pMod
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pMod->idCtx
-//
-// ippStsBadArgErr 160 != bitsize(pMOd)
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pMod pointer to the 160-bit modulus
-// pRnd pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGSetModulus, (const IppsBigNumState* pMod, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr);
-
- /* test modulus */
- IPP_BAD_PTR1_RET(pMod);
- pMod = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMod, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pMod), ippStsContextMatchErr);
- IPP_BADARG_RET(160 != BITSIZE_BNU(BN_NUMBER(pMod),BN_SIZE(pMod)), ippStsBadArgErr);
-
- ZEXPAND_COPY_BNU(RAND_Q(pRnd), (int)(sizeof(RAND_Q(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pMod), BN_SIZE(pMod));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsPRNGSetH0
-//
-// Purpose: Sets 160-bit parameter of G() function.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pH0
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pH0->idCtx
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pH0 pointer to the parameter used into G() function
-// pRnd pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGSetH0,(const IppsBigNumState* pH0, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr);
-
- /* test H0 */
- IPP_BAD_PTR1_RET(pH0);
- pH0 = (IppsBigNumState*)( IPP_ALIGNED_PTR(pH0, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pH0), ippStsContextMatchErr);
-
- {
- cpSize len = IPP_MIN(5, BN_SIZE(pH0)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)));
- ZEXPAND_BNU(RAND_T(pRnd), 0, (int)(sizeof(RAND_T(pRnd))/sizeof(BNU_CHUNK_T)));
- ZEXPAND_COPY_BNU((Ipp32u*)RAND_T(pRnd), (int)(sizeof(RAND_T(pRnd))/sizeof(Ipp32u)),
- (Ipp32u*)BN_NUMBER(pH0), len);
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsPRNGSetSeed
-//
-// Purpose: Sets the initial state with the SEED value
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pSeed
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pSeed->idCtx
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pSeed pointer to the SEED
-// pRnd pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGSetSeed, (const IppsBigNumState* pSeed, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr);
-
- /* test seed */
- IPP_BAD_PTR1_RET(pSeed);
- pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr);
-
- {
- cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pRnd) );
- BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd));
- cpSize size = IPP_MIN(BN_SIZE(pSeed), argSize);
-
- ZEXPAND_COPY_BNU(RAND_XKEY(pRnd), (cpSize)(sizeof(RAND_XKEY(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pSeed), size);
- RAND_XKEY(pRnd)[argSize-1] &= mask;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsPRNGSetAugment
-//
-// Purpose: Sets the Entropy Augmentation
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pAug
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pAug->idCtx
-//
-// ippStsLengthErr nBits < 1
-// nBits > MAX_XKEY_SIZE
-// ippStsNoErr no error
-//
-// Parameters:
-// pAug pointer to the entropy eugmentation
-// pRnd pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGSetAugment, (const IppsBigNumState* pAug, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr);
-
- /* test augmentation */
- IPP_BAD_PTR1_RET(pAug);
- pAug = (IppsBigNumState*)( IPP_ALIGNED_PTR(pAug, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pAug), ippStsContextMatchErr);
-
- {
- cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pRnd) );
- BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd));
- cpSize size = IPP_MIN(BN_SIZE(pAug), argSize);
-
- ZEXPAND_COPY_BNU(RAND_XAUGMENT(pRnd), (cpSize)(sizeof(RAND_XAUGMENT(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pAug), size);
- RAND_XAUGMENT(pRnd)[argSize-1] &= mask;
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsPRNGGetSeed
-//
-// Purpose: Get current SEED value from the state
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-// NULL == pSeed
-//
-// ippStsContextMatchErr illegal pRnd->idCtx
-// illegal pSeed->idCtx
-// ippStsOutOfRangeErr lengtrh of the actual SEED > length SEED destination
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pRnd pointer to the context
-// pSeed pointer to the SEED
-*F*/
-IPPFUN(IppStatus, ippsPRNGGetSeed, (const IppsPRNGState* pRnd, IppsBigNumState* pSeed))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr);
-
- /* test seed */
- IPP_BAD_PTR1_RET(pSeed);
- pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr);
-
- return ippsSet_BN(ippBigNumPOS,
- BITS2WORD32_SIZE(RAND_SEEDBITS(pRnd)),
- (Ipp32u*)RAND_XKEY(pRnd),
- pSeed);
-}
diff --git a/ext/ipp/sources/ippcp/src/pcpsha256ca.c b/ext/ipp/sources/ippcp/src/pcpsha256ca.c
deleted file mode 100644
index 3ccb54a..0000000
--- a/ext/ipp/sources/ippcp/src/pcpsha256ca.c
+++ /dev/null
@@ -1,814 +0,0 @@
-/*############################################################################
- # Copyright 1999-2018 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*
-//
-// Purpose:
-// Cryptography Primitive.
-// Digesting message according to SHA256
-//
-// Contents:
-// ippsSHA256GetSize()
-// ippsSHA256Init()
-// ippsSHA256Pack()
-// ippsSHA256Unpack()
-// ippsSHA256Duplicate()
-// ippsSHA256Update()
-// ippsSHA256GetTag()
-// ippsSHA256Final()
-// ippsSHA256MessageDigest()
-//
-//
-*/
-
-#include "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcphash_rmf.h"
-#include "pcptool.h"
-
-/* SHA-256, SHA-224 constants */
-static const Ipp32u sha256_iv[] = {
- 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
- 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19};
-static const Ipp32u sha224_iv[] = {
- 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939,
- 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4};
-
-static __ALIGN16 const Ipp32u sha256_cnt[] = {
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
-};
-
-
-/* setup init hash value */
-__INLINE void hashInit(Ipp32u* pHash, const Ipp32u* iv)
-{
- pHash[0] = iv[0];
- pHash[1] = iv[1];
- pHash[2] = iv[2];
- pHash[3] = iv[3];
- pHash[4] = iv[4];
- pHash[5] = iv[5];
- pHash[6] = iv[6];
- pHash[7] = iv[7];
-}
-static void sha256_hashInit(void* pHash)
-{
- hashInit((Ipp32u*)pHash, sha256_iv);
-}
-static void sha224_hashInit(void* pHash)
-{
- hashInit((Ipp32u*)pHash, sha224_iv);
-}
-
-static void sha256_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
-{
- UpdateSHA256(pHash, pMsg, msgLen, sha256_cnt);
-}
-#if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
-static void sha256_ni_hashUpdate(void* pHash, const Ipp8u* pMsg, int msgLen)
-{
- UpdateSHA256ni(pHash, pMsg, msgLen, sha256_cnt);
-}
-#endif
-
-/* convert hash into big endian */
-static void sha256_hashOctString(Ipp8u* pMD, void* pHashVal)
-{
- /* convert hash into big endian */
- ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
- ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
- ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
- ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
- ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
- ((Ipp32u*)pMD)[5] = ENDIANNESS32(((Ipp32u*)pHashVal)[5]);
- ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[6]);
- ((Ipp32u*)pMD)[7] = ENDIANNESS32(((Ipp32u*)pHashVal)[7]);
-}
-static void sha224_hashOctString(Ipp8u* pMD, void* pHashVal)
-{
- /* convert hash into big endian */
- ((Ipp32u*)pMD)[0] = ENDIANNESS32(((Ipp32u*)pHashVal)[0]);
- ((Ipp32u*)pMD)[1] = ENDIANNESS32(((Ipp32u*)pHashVal)[1]);
- ((Ipp32u*)pMD)[2] = ENDIANNESS32(((Ipp32u*)pHashVal)[2]);
- ((Ipp32u*)pMD)[3] = ENDIANNESS32(((Ipp32u*)pHashVal)[3]);
- ((Ipp32u*)pMD)[4] = ENDIANNESS32(((Ipp32u*)pHashVal)[4]);
- ((Ipp32u*)pMD)[5] = ENDIANNESS32(((Ipp32u*)pHashVal)[5]);
- ((Ipp32u*)pMD)[6] = ENDIANNESS32(((Ipp32u*)pHashVal)[6]);
-}
-
-static void sha256_msgRep(Ipp8u* pDst, Ipp64u lenLo, Ipp64u lenHi)
-{
- UNREFERENCED_PARAMETER(lenHi);
- lenLo = ENDIANNESS64(lenLo<<3);
- ((Ipp64u*)(pDst))[0] = lenLo;
-}
-
-
-/*
-// SHA256 init context
-*/
-static IppStatus GetSizeSHA256(int* pSize)
-{
- IPP_BAD_PTR1_RET(pSize);
- *pSize = sizeof(IppsSHA256State) +(SHA256_ALIGNMENT-1);
- return ippStsNoErr;
-}
-
-static IppStatus InitSHA256(IppsSHA256State* pState, const DigestSHA256 IV)
-{
- /* test state pointer */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
-
- HASH_CTX_ID(pState) = idCtxSHA256;
- HASH_LENLO(pState) = 0;
- HAHS_BUFFIDX(pState) = 0;
-
- /* setup initial digest */
- HASH_VALUE(pState)[0] = IV[0];
- HASH_VALUE(pState)[1] = IV[1];
- HASH_VALUE(pState)[2] = IV[2];
- HASH_VALUE(pState)[3] = IV[3];
- HASH_VALUE(pState)[4] = IV[4];
- HASH_VALUE(pState)[5] = IV[5];
- HASH_VALUE(pState)[6] = IV[6];
- HASH_VALUE(pState)[7] = IV[7];
-
- return ippStsNoErr;
-}
-
-/*F*
-// Name: ippsSHA256GetSize
-// ippsSHA224GetSize
-//
-// Purpose: Returns size (bytes) of IppsSHA256State state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to state size
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256GetSize,(int* pSize))
-{
- return GetSizeSHA256(pSize);
-}
-IPPFUN(IppStatus, ippsSHA224GetSize,(int* pSize))
-{
- return GetSizeSHA256(pSize);
-}
-
-
-/*F*
-// Name: ippsSHA256Init
-// ippsSHA224Init
-//
-// Purpose: Init SHA256
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pState pointer to the SHA512 state
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Init,(IppsSHA256State* pState))
-{
- return InitSHA256(pState, sha256_iv);
-}
-IPPFUN(IppStatus, ippsSHA224Init,(IppsSHA224State* pState))
-{
- return InitSHA256(pState, sha224_iv);
-}
-
-
-/*F*
-// Name: ippsSHA256Pack
-// ippsSHA224Pack
-//
-// Purpose: Copy initialized context to the buffer.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// pBuffer == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer to the hash state
-// pBuffer pointer to the destination buffer
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pCtx, Ipp8u* pBuffer))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
- pCtx = (IppsSHA256State*)( IPP_ALIGNED_PTR(pCtx, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pCtx), ippStsContextMatchErr);
-
- CopyBlock(pCtx, pBuffer, sizeof(IppsSHA256State));
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pCtx, Ipp8u* pBuffer))
-{
- return ippsSHA256Pack(pCtx, pBuffer);
-}
-
-
-/*F*
-// Name: ippsSHA256Unpack
-// ippsSHA224Unpack
-//
-// Purpose: Unpack buffer content into the initialized context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// pBuffer == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBuffer pointer to the input buffer
-// pCtx pointer hash state
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pCtx))
-{
- /* test pointers */
- IPP_BAD_PTR2_RET(pCtx, pBuffer);
- pCtx = (IppsSHA256State*)( IPP_ALIGNED_PTR(pCtx, SHA256_ALIGNMENT) );
-
- CopyBlock(pBuffer, pCtx, sizeof(IppsSHA256State));
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pCtx))
-{
- return ippsSHA256Unpack(pBuffer, pCtx);
-}
-
-
-/*F*
-// Name: ippsSHA256Duplicate
-// ippsSHA224Duplicate
-//
-// Purpose: Clone SHA256 state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrcState == NULL
-// pDstState == NULL
-// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA256
-// pDstState->idCtx != idCtxSHA256
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrcState pointer to the source SHA256 state
-// pDstState pointer to the target SHA256 state
-//
-// Note:
-// pDstState may to be uninitialized by ippsSHA256Init()
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcState, IppsSHA256State* pDstState))
-{
- /* test state pointers */
- IPP_BAD_PTR2_RET(pSrcState, pDstState);
- pSrcState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pSrcState, SHA256_ALIGNMENT) );
- pDstState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pDstState, SHA256_ALIGNMENT) );
- /* test states ID */
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pSrcState), ippStsContextMatchErr);
-
- /* copy state */
- CopyBlock(pSrcState, pDstState, sizeof(IppsSHA256State));
-
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcState, IppsSHA224State* pDstState))
-{
- return ippsSHA256Duplicate(pSrcState, pDstState);
-}
-
-
-/*F*
-// Name: ippsSHA256Update
-// ippsSHA224Update
-//
-// Purpose: Updates intermadiate digest based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrc == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxSHA256
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pState pointer to the SHA256 state
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pState))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
-
- /* test input length */
- IPP_BADARG_RET((len<0), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- /*
- // handle non empty message
- */
- if(len) {
- /* select processing function */
- #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
- cpHashProc updateFunc = UpdateSHA256ni;
- #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
- cpHashProc updateFunc = IsFeatureEnabled(SHA_NI_ENABLED)? UpdateSHA256ni : UpdateSHA256;
- #else
- cpHashProc updateFunc = UpdateSHA256;
- #endif
-
- int procLen;
-
- int idx = HAHS_BUFFIDX(pState);
- Ipp8u* pBuffer = HASH_BUFF(pState);
- Ipp64u lenLo = HASH_LENLO(pState) +len;
-
- /* if non empty internal buffer filling */
- if(idx) {
- /* copy from input stream to the internal buffer as match as possible */
- procLen = IPP_MIN(len, (MBS_SHA256-idx));
- CopyBlock(pSrc, pBuffer+idx, procLen);
-
- /* update message pointer and length */
- pSrc += procLen;
- len -= procLen;
- idx += procLen;
-
- /* update digest if buffer full */
- if( MBS_SHA256 == idx) {
- updateFunc(HASH_VALUE(pState), pBuffer, MBS_SHA256, sha256_cnt);
- idx = 0;
- }
- }
-
- /* main message part processing */
- procLen = len & ~(MBS_SHA256-1);
- if(procLen) {
- updateFunc(HASH_VALUE(pState), pSrc, procLen, sha256_cnt);
- pSrc += procLen;
- len -= procLen;
- }
-
- /* store rest of message into the internal buffer */
- if(len) {
- CopyBlock(pSrc, pBuffer, len);
- idx += len;
- }
-
- /* update length of processed message */
- HASH_LENLO(pState) = lenLo;
- HAHS_BUFFIDX(pState) = idx;
- }
-
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pState))
-{
- return ippsSHA256Update(pSrc, len, pState);
-}
-
-
-static void cpFinalizeSHA256(DigestSHA256 pHash, const Ipp8u* inpBuffer, int inpLen, Ipp64u processedMsgLen)
-{
- /* select processing function */
- #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
- cpHashProc updateFunc = UpdateSHA256ni;
- #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
- cpHashProc updateFunc = IsFeatureEnabled(SHA_NI_ENABLED)? UpdateSHA256ni : UpdateSHA256;
- #else
- cpHashProc updateFunc = UpdateSHA256;
- #endif
-
- /* local buffer and it length */
- Ipp8u buffer[MBS_SHA256*2];
- int bufferLen = inpLen < (MBS_SHA256-(int)MLR_SHA256)? MBS_SHA256 : MBS_SHA256*2;
-
- /* copy rest of message into internal buffer */
- CopyBlock(inpBuffer, buffer, inpLen);
-
- /* padd message */
- buffer[inpLen++] = 0x80;
- PaddBlock(0, buffer+inpLen, bufferLen-inpLen-MLR_SHA256);
-
- /* put processed message length in bits */
- processedMsgLen = ENDIANNESS64(processedMsgLen<<3);
- ((Ipp64u*)(buffer+bufferLen))[-1] = processedMsgLen;
-
- /* copmplete hash computation */
- updateFunc(pHash, buffer, bufferLen, sha256_cnt);
-}
-
-/*F*
-// Name: ippsSHA256Final
-// ippsSHA224Final
-//
-// Purpose: Stop message digesting and return digest.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pDigest == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxSHA256
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// pState pointer to the SHA256 state
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pState))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
-
- cpFinalizeSHA256(HASH_VALUE(pState), HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
- /* convert hash into big endian */
- ((Ipp32u*)pMD)[0] = ENDIANNESS32(HASH_VALUE(pState)[0]);
- ((Ipp32u*)pMD)[1] = ENDIANNESS32(HASH_VALUE(pState)[1]);
- ((Ipp32u*)pMD)[2] = ENDIANNESS32(HASH_VALUE(pState)[2]);
- ((Ipp32u*)pMD)[3] = ENDIANNESS32(HASH_VALUE(pState)[3]);
- ((Ipp32u*)pMD)[4] = ENDIANNESS32(HASH_VALUE(pState)[4]);
- ((Ipp32u*)pMD)[5] = ENDIANNESS32(HASH_VALUE(pState)[5]);
- ((Ipp32u*)pMD)[6] = ENDIANNESS32(HASH_VALUE(pState)[6]);
- ((Ipp32u*)pMD)[7] = ENDIANNESS32(HASH_VALUE(pState)[7]);
-
- /* re-init hash value */
- HAHS_BUFFIDX(pState) = 0;
- HASH_LENLO(pState) = 0;
- sha256_hashInit(HASH_VALUE(pState));
-
- return ippStsNoErr;
-}
-
-IPPFUN(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pState))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
-
- cpFinalizeSHA256(HASH_VALUE(pState), HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
- /* convert hash into big endian */
- ((Ipp32u*)pMD)[0] = ENDIANNESS32(HASH_VALUE(pState)[0]);
- ((Ipp32u*)pMD)[1] = ENDIANNESS32(HASH_VALUE(pState)[1]);
- ((Ipp32u*)pMD)[2] = ENDIANNESS32(HASH_VALUE(pState)[2]);
- ((Ipp32u*)pMD)[3] = ENDIANNESS32(HASH_VALUE(pState)[3]);
- ((Ipp32u*)pMD)[4] = ENDIANNESS32(HASH_VALUE(pState)[4]);
- ((Ipp32u*)pMD)[5] = ENDIANNESS32(HASH_VALUE(pState)[5]);
- ((Ipp32u*)pMD)[6] = ENDIANNESS32(HASH_VALUE(pState)[6]);
-
- /* re-init hash value */
- HAHS_BUFFIDX(pState) = 0;
- HASH_LENLO(pState) = 0;
- sha224_hashInit(HASH_VALUE(pState));
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsSHA256GetTag
-// ippsSHA224GetTag
-//
-// Purpose: Compute digest based on current state.
-// Note, that futher digest update is possible
-//
-// Returns: Reason:
-// ippStsNullPtrErr pTag == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxSHA256
-// ippStsLengthErr max_SHA_digestLen < tagLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pTag address of the output digest
-// tagLen length of digest
-// pState pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pState))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pTag);
- IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA256)<tagLen), ippStsLengthErr);
-
- {
- DigestSHA256 digest;
- CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA256));
- cpFinalizeSHA256(digest, HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
- digest[0] = ENDIANNESS32(digest[0]);
- digest[1] = ENDIANNESS32(digest[1]);
- digest[2] = ENDIANNESS32(digest[2]);
- digest[3] = ENDIANNESS32(digest[3]);
- digest[4] = ENDIANNESS32(digest[4]);
- digest[5] = ENDIANNESS32(digest[5]);
- digest[6] = ENDIANNESS32(digest[6]);
- digest[7] = ENDIANNESS32(digest[7]);
- CopyBlock(digest, pTag, tagLen);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsSHA224GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA224State* pState))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pState);
- pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) );
- IPP_BADARG_RET(idCtxSHA256 !=HASH_CTX_ID(pState), ippStsContextMatchErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pTag);
- IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA224)<tagLen), ippStsLengthErr);
-
- {
- DigestSHA256 digest;
- CopyBlock(HASH_VALUE(pState), digest, sizeof(DigestSHA256));
- cpFinalizeSHA256(digest, HASH_BUFF(pState), HAHS_BUFFIDX(pState), HASH_LENLO(pState));
- digest[0] = ENDIANNESS32(digest[0]);
- digest[1] = ENDIANNESS32(digest[1]);
- digest[2] = ENDIANNESS32(digest[2]);
- digest[3] = ENDIANNESS32(digest[3]);
- digest[4] = ENDIANNESS32(digest[4]);
- digest[5] = ENDIANNESS32(digest[5]);
- digest[6] = ENDIANNESS32(digest[6]);
- digest[7] = ENDIANNESS32(digest[7]);
- CopyBlock(digest, pTag, tagLen);
-
- return ippStsNoErr;
- }
-}
-
-
-static IppStatus cpSHA256MessageDigest(DigestSHA256 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA256 IV)
-{
- /* test digest pointer */
- IPP_BAD_PTR1_RET(hash);
- /* test message length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- /* test message pointer */
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- {
- /* select processing function */
- #if (_SHA_NI_ENABLING_==_FEATURE_ON_)
- cpHashProc updateFunc = UpdateSHA256ni;
- #elif (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_)
- cpHashProc updateFunc = IsFeatureEnabled(SHA_NI_ENABLED)? UpdateSHA256ni : UpdateSHA256;
- #else
- cpHashProc updateFunc = UpdateSHA256;
- #endif
-
- /* message length in the multiple MBS and the rest */
- int msgLenBlks = msgLen & (-MBS_SHA256);
- int msgLenRest = msgLen - msgLenBlks;
-
- /* init hash */
- hash[0] = IV[0];
- hash[1] = IV[1];
- hash[2] = IV[2];
- hash[3] = IV[3];
- hash[4] = IV[4];
- hash[5] = IV[5];
- hash[6] = IV[6];
- hash[7] = IV[7];
-
- /* process main part of the message */
- if(msgLenBlks) {
- updateFunc(hash, pMsg, msgLenBlks, sha256_cnt);
- pMsg += msgLenBlks;
- }
-
- cpFinalizeSHA256(hash, pMsg, msgLenRest, msgLen);
- hash[0] = ENDIANNESS32(hash[0]);
- hash[1] = ENDIANNESS32(hash[1]);
- hash[2] = ENDIANNESS32(hash[2]);
- hash[3] = ENDIANNESS32(hash[3]);
- hash[4] = ENDIANNESS32(hash[4]);
- hash[5] = ENDIANNESS32(hash[5]);
- hash[6] = ENDIANNESS32(hash[6]);
- hash[7] = ENDIANNESS32(hash[7]);
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsSHA256MessageDigest,
-// ippsSHA224MessageDigest
-//
-// Purpose: Digest of the whole message.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMsg == NULL
-// pDigest == NULL
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the input message
-// len input message length
-// pMD address of the output digest
-//
-*F*/
-IPPFUN(IppStatus, ippsSHA256MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD))
-{
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
-
- {
- DigestSHA256 hash;
- IppStatus sts = cpSHA256MessageDigest(hash, pMsg, msgLen, sha256_iv);
- if(ippStsNoErr==sts)
- CopyBlock(hash, pMD, IPP_SHA256_DIGEST_BITSIZE/BYTESIZE);
- return sts;
- }
-}
-
-IPPFUN(IppStatus, ippsSHA224MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD))
-{
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
-
- {
- DigestSHA256 hash;
- IppStatus sts = cpSHA256MessageDigest(hash, pMsg, msgLen, sha224_iv);
- if(ippStsNoErr==sts)
- CopyBlock(hash, pMD, IPP_SHA224_DIGEST_BITSIZE/BYTESIZE);
- return sts;
- }
-}
-
-
-/*
-// available SHA256 methods
-*/
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256, (void) )
-{
- static IppsHashMethod method = {
- ippHashAlg_SHA256,
- IPP_SHA256_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha256_hashInit,
- sha256_hashUpdate,
- sha256_hashOctString,
- sha256_msgRep
- };
- return &method;
-}
-
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256_NI, (void) )
-{
- #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
- static IppsHashMethod method = {
- ippHashAlg_SHA256,
- IPP_SHA256_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha256_hashInit,
- sha256_ni_hashUpdate,
- sha256_hashOctString,
- sha256_msgRep
- };
- return &method;
- #else
- return NULL;
- #endif
-}
-
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA256_TT, (void) )
-{
- static IppsHashMethod method = {
- ippHashAlg_SHA256,
- IPP_SHA256_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha256_hashInit,
- sha256_hashUpdate,
- sha256_hashOctString,
- sha256_msgRep
- };
- #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
- if(IsFeatureEnabled(SHA_NI_ENABLED))
- method.hashUpdate = sha256_ni_hashUpdate;
- #endif
- return &method;
-}
-
-/*
-// available SHA224 methods
-*/
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224, (void) )
-{
- static IppsHashMethod method = {
- ippHashAlg_SHA224,
- IPP_SHA224_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha224_hashInit,
- sha256_hashUpdate,
- sha224_hashOctString,
- sha256_msgRep
- };
- return &method;
-}
-
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224_NI, (void) )
-{
- #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
- static IppsHashMethod method = {
- ippHashAlg_SHA224,
- IPP_SHA224_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha224_hashInit,
- sha256_ni_hashUpdate,
- sha224_hashOctString,
- sha256_msgRep
- };
- return &method;
- #else
- return NULL;
- #endif
-}
-
-IPPFUN( const IppsHashMethod*, ippsHashMethod_SHA224_TT, (void) )
-{
- static IppsHashMethod method = {
- ippHashAlg_SHA224,
- IPP_SHA224_DIGEST_BITSIZE/8,
- MBS_SHA256,
- MLR_SHA256,
- sha224_hashInit,
- sha256_hashUpdate,
- sha224_hashOctString,
- sha256_msgRep
- };
- #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_ || _SHA_NI_ENABLING_==_FEATURE_ON_)
- if(IsFeatureEnabled(SHA_NI_ENABLED))
- method.hashUpdate = sha256_ni_hashUpdate;
- #endif
- return &method;
-}