Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6731 Discussions

Suspected Bug: ippsGFpECSignDSA generates small signatures when AVX-512F is enabled

Crypto_P
Beginner
830 Views

The following code fails to produce a valid signature when AVX-512F is enabled but works when it is disabled:

 

 

Ipp64u mask = 0;
        IppStatus ret = ippcpGetCpuFeatures(&mask);
        //ret = ippcpSetCpuFeatures(mask^ippCPUID_AVX512IFMA); //when this step is uncommented the below code verifies
        

        int buffer_size = 0;
        ippsGFpGetSize(256, &buffer_size);
        IppsGFpState* galois_field = (IppsGFpState*) (new Ipp8u [buffer_size]);
        ippsGFpInitFixed(256, ippsGFpMethod_p256r1(), galois_field);

        buffer_size = 0;
        ippsGFpECGetSize(galois_field, &buffer_size);
        IppsGFpECState* elliptic_curve = (IppsGFpECState*) (new Ipp8u [buffer_size]);
        ippsGFpECInitStd256r1(galois_field, elliptic_curve);

        buffer_size = 0;
        ippsGFpECScratchBufferSize( 1, elliptic_curve, &buffer_size);
        Ipp8u* scratch_buffer = new Ipp8u [buffer_size];

        IppECResult res  = ippECInvalidSignature;
        ippsGFpECVerify( &res, elliptic_curve,  scratch_buffer);

        int big_num_size = 0;
        auto word_size = BITSIZE_WORD(static_cast<int>(80*8));
        ippsBigNumGetSize(word_size, &big_num_size);

        IppsBigNumState* secret_key = (IppsBigNumState*)(new Ipp8u [big_num_size]);
        IppsBigNumState* eph_secret_key = (IppsBigNumState*)(new Ipp8u [big_num_size]);
        IppsBigNumState* sig_y = (IppsBigNumState*)(new Ipp8u [big_num_size]);
        IppsBigNumState* sig_x = (IppsBigNumState*)(new Ipp8u [big_num_size]);
        IppsBigNumState* message = (IppsBigNumState*)(new Ipp8u [big_num_size]);
        
        ippsBigNumInit(word_size, secret_key);
        ippsBigNumInit(word_size, message);
        ippsBigNumInit(word_size, eph_secret_key);
        ippsBigNumInit(word_size, sig_y);
        ippsBigNumInit(word_size, sig_x);

        ippsGFpECPrivateKey(secret_key, elliptic_curve, (IppBitSupplier) /*prng*/, NULL);
        ippsGFpECPrivateKey(eph_secret_key, elliptic_curve, (IppBitSupplier) /*prng*/, NULL);

        buffer_size = 0;
        ippsGFpECScratchBufferSize(1, elliptic_curve, &buffer_size);
        
        delete [] (Ipp8u*)scratch_buffer;
        scratch_buffer = new Ipp8u [buffer_size];

        buffer_size = 0;
        ippsGFpECPointGetSize(elliptic_curve, &buffer_size);
        IppsGFpECPoint* public_key = (IppsGFpECPoint*)(new Ipp8u[buffer_size]);
        
        ippsGFpECPointInit(NULL, NULL, public_key, elliptic_curve);
        ippsGFpECPublicKey(secret_key, public_key, elliptic_curve, scratch_buffer);

        //assuming msg_data is within the order of the curve
        ippsSet_BN(IppsBigNumPOS, /*msg_data_size*/, /*msg_data*/, message);

        delete [] (Ipp8u*)scratch_buffer;
        buffer_size = 0;
        ippsGFpECScratchBufferSize(1, elliptic_curve, &buffer_size);
        scratch_buffer = new Ipp8u [buffer_size];

        ippsGFpECSignDSA(message, secret_key, eph_secret_key, sig_x, sig_y, elliptic_curve, scratch_buffer);

        delete [] (Ipp8u*)scratch_buffer;
        scratch_buffer = new Ipp8u [buffer_size];

        IppECResult pResult = ippECInvalidSignature;
        ippsGFpECVerifyDSA(message, public_key, sig_x, sig_y, &pResult, elliptic_curve, scratch_buffer);
        if(pResult == ippECValid)
        {
            //pResult ends up being invalid
        }

 

Im using the following version of ippcp: ippCP AVX-512F/CD/BW/DQ/VL/SHA/VBMI/VBMI2/IFMA/GFNI/VAES/VCLMUL (k1) 2021.7.0 (11.5 ) (-)

0 Kudos
3 Replies
VarshaS_Intel
Moderator
796 Views

Hi,


Thanks for posting in Intel Communities.


Could you please let us know your OS details you are using?


Could you please provide us with the complete sample reproducer code along with the complete steps you had followed to reproducer your issue at our end?


Thanks & Regards,

Varsha


0 Kudos
VarshaS_Intel
Moderator
722 Views

Hi,


We have not heard back from you. Could you please provide us an update on your issue?


Thanks & Regards,

Varsha


0 Kudos
VarshaS_Intel
Moderator
684 Views

Hi,


We have not heard back from you. Cold you please provide us with an update on your issue?


Thanks & Regards,

Varsha


0 Kudos
Reply