I'm trying to use the "Functions based on SM2" for ECIES - encryption and decryption based on eliptic curves. The problem is that i can't find a way to properly initialize an elliptic curve using the encryption scheme (IppsGFpECState). In the Developer Reference for Intel® IPP Cryptography there are two function that seems to be what i need but i can't figured it out how to use them. I'm talking about: GFpECESGetSize_SM2 and GFpECESInit_SM2. With this how can i properly initialize an IppsGFpECState?
Thanks in advance.
Thank you for application.
You are absolutely right, to initialize ECIES scheme you should call ippsGFpECESGetSize_SM2() and ippsGFpECESInit_SM2() functions.
Take a look at the dellarations of these 2 funtions:
IppStatus ippsGFpECESGetSize_SM2(const IppsGFpECState* pEC, int* pSize);
IppStatus ippsGFpECESInit_SM2(IppsGFpECState* pEC, IppsECESState_SM2* pState, int avaliableCtxSize);
Both are requires EC (elliptic curve) being constructed before.
How to do that? Right, call ippsGFpECGetSize() and ippsGFpECInit() functions.
Take a look at the dellarations of these 2 functions:
IppStatus ippsGFpECGetSize(const IppsGFpState* pGFp, int* pSize);
IppStatus ippsGFpECInit(const IppsGFpState* pGFp, const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpECState* pEC);
Againg we see that underlying GF must be constructed before. And here, againg, GetSize and Init will help us.
So, you need:
1) construct GF (call ippsGFpGetSize() and the most suitable suitable for you GFpInit function
(ippsGFpInitArbitrary or ippsGFpInitFixed or ippsGFpInit))
2) construct EC over GF (call ippsGFpECGetSize() and ippsGFpECInit())
3) and the last step - init ESIES sheeme - use ippsGFpECESGetSize_SM2() and ippsGFpECESInit_SM2()
Let us know if something stayed unclear and we provide more details.