Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

something wrong with Functions based on SM2 #21

Closed
DaiJiaKang opened this issue Jul 2, 2020 · 7 comments
Closed

something wrong with Functions based on SM2 #21

DaiJiaKang opened this issue Jul 2, 2020 · 7 comments

Comments

@DaiJiaKang
Copy link

i want to use SM2 API.
first, i create IppsGFpState with ippsGFpMethod_p256sm2 & bignum P, and then i know the A, B, X, Y, N of the ECC
second, i create IppsGFpECState and figure out the publicKey & privatekey
third, i want to create IppsECES_StateSM2. At the same time, something wrong, i always get the ippStsNotSupportedModeErr err when calling the IppStatus ippsGFpECESGetSize_SM2(const IppsGFpECState* pEC, int* pSize);
this is my ECC parameter:
Ipp8u P_str[] = "\xFF\xFF\xFF\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
Ipp8u A_str[] = "\xFF\xFF\xFF\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC";
Ipp8u B_str[] = "\x28\xE9\xFA\x9E\x9D\x9F\x5E\x34\x4D\x5A\x9E\x4B\xCF\x65\x09\xA7\xF3\x97\x89\xF5\x15\xAB\x8F\x92\xDD\xBC\xBD\x41\x4D\x94\x0E\x93";
Ipp8u X_str[] = "\x32\xC4\xAE\x2C\x1F\x19\x81\x19\x5F\x99\x04\x46\x6A\x39\xC9\x94\x8F\xE3\x0B\xBF\xF2\x66\x0B\xE1\x71\x5A\x45\x89\x33\x4C\x74\xC7";
Ipp8u Y_str[] = "\xBC\x37\x36\xA2\xF4\xF6\x77\x9C\x59\xBD\xCE\xE3\x6B\x69\x21\x53\xD0\xA9\x87\x7C\xC6\x2A\x47\x40\x02\xDF\x32\xE5\x21\x39\xF0\xA0";
Ipp8u N_str[] = "\xFF\xFF\xFF\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x72\x03\xDF\x6B\x21\xC6\x05\x2B\x53\xBB\xF4\x09\x39\xD5\x41\x23";
help me pls!

@skirillo
Copy link

It seems the only situation where ippsGFpECESGetSize_SM2() returns the ippStsNotSupportedModeErr status is incorrect initialization of the Elliptic Curve (or underlying finite field). If you send a short example illustrating this problem, it helps to understand the source of issue and fix it.
By the way, the SM2 curve has fixed P, A, B, X, Y and N parameters, Are you sure your values (above) are corresponds to SM2 EC?

@DaiJiaKang
Copy link
Author

@skirillo

example.zip

@skirillo
Copy link

In your example I did not find the following:
'ipp_print_BN' undefined; assuming extern returning int
'ipp_getBN_pint' undefined; assuming extern returning int
'get_time_seed' undefined; assuming extern returning int
'ipp_ramdom_init' undefined; assuming extern returning int
'ipp_random_BN_get' undefined; assuming extern returning int
'ipp_mod_BN' undefined; assuming extern returning int
'ipp_delete_BN' undefined; assuming extern returning int
'ipp_random_release' undefined; assuming extern returning int
Could you prepare compete example?

@DaiJiaKang
Copy link
Author

example.zip
@skirillo

@skirillo
Copy link

You sample is not complete. Undefined ipp_extget_BN function.

@skirillo
Copy link

when EC created the underlying field is not copied into EC state but instead saved the pointer to GF state only.
In the ipp_ecc_ende_sm2Gen() GF state created correctly but DESTROYED before return.
The ipp_ecc_ende_sm2init() require correct content of EC state including reference to GF state. But it destroyed ..
It's the reason why ippsGFpECESGetSize_SM2() returns error status.

I recommend to take a look at SM2 encryption/decryption protocol

@DaiJiaKang
Copy link
Author

i get it,thank u very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants