intel / cryptography-primitives

Intel® Cryptography Primitives Library is a secure, fast and lightweight library of building blocks for cryptography, highly-optimized for various Intel® CPUs
Apache License 2.0
327 stars 86 forks source link

Question about function fesm2_mul and ifma_amm52_psm2_ #66

Closed YWRtaW4 closed 11 months ago

YWRtaW4 commented 12 months ago

Hi,

It seems to me that function fesm2_mul from sources/ippcp/sm2/ifma_arith_psm2.c implements multiplication modular sm2_p using CIOS Montgomery multiplication, and that the function ifma_amm52_psm2_ from sources/ippcp/cryoto_mb/src/sm2/ifma_arith_psm2.c also implements multiplication modular multiplication modular sm2_p by first multiplying, then applying fast reduction. Both methods use AVX512IFMA instruction.

I'm confused about which implementation to use on the k1, namely IceLake platform. Could you provide any performance data or other suggestions? Thank you very much.

paveldyakov commented 12 months ago

Hi @YWRtaW4,

As I can see, one implementation is related to Single-buffer SM2 algorithm - https://www.intel.com/content/www/us/en/docs/ipp-crypto/developer-guide-reference/2021-9/functions-based-on-sm2.html The second one is for Multi-buffer SM2 algorithm - https://www.intel.com/content/www/us/en/docs/ipp-crypto/developer-guide-reference/2021-9/sm2-elliptic-curve-functions.html

Please review the documentation and API - probably it can help you to decide which function works best for your case

Please let us know if you have any more questions

paveldyakov commented 11 months ago

@YWRtaW4, could you please let us know if any help is required?

paveldyakov commented 11 months ago

Hope the provided information helped. Closing the issue because of no response.

yellow123Nike commented 11 months ago

Do you use ifma_mb8_to_HexStr8() please? I always get an error when I convert from mb8 to string8