cancel
Showing results for 
Search instead for 
Did you mean: 

ECC example in CRYP-LIB with STM32 F407

naruhodoh2006
Associate
Posted on July 02, 2014 at 08:54

Hello,

I have tried ECC_KeyGeneration_SignatureVerification example in STM32-CRYP-LIB with STM32 F407 (toolchain is IAR)

But, when ''Generate ECC key pair'' be executed, the status be changed to FAILED (value:6002 RNG_ERR_BAD_OPERATION).

Does anyone can execute this example with STM32 F470?

How can I fix it?

Thank you

Naruhodo

#crypto #ecc.h #stm32f4 #discovery
7 REPLIES 7
Posted on July 02, 2014 at 13:20

Evidently it uses the RNG (Random Number Generator) hardware, which is not functioning. Check that it's enabled, clocked, and that you are using the PLL to clock the part as the RNG/SDIO are dependent on a ~48 MHz on the Q Tap

STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\RNG\RNG_MultiRNG

static void RNG_Config(void)
{
/* Enable RNG clock source */
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);
/* RNG Peripheral enable */
RNG_Cmd(ENABLE);
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
adnan2
Associate
Posted on July 21, 2014 at 14:06

Hi,

I am using ECCscalarMUL function and there is no error but i am unable to verify my test vectors. I am using the sample code giving in the lib for 160 bit curve.

Please Help.

Best Regards,

Ibrahim

Posted on July 21, 2014 at 17:36

I am using ECCscalarMUL function and there is no error but i am unable to verify my test vectors. I am using the sample code giving in the lib for 160 bit curve.

Not sure how I'm going to be able to independently verify that, but ...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
adnan2
Associate
Posted on July 23, 2014 at 00:50

Thanks for the reply.

I have used the portion of code in ecc.h that is used to compute scalar multiplication for 160 bits.

This code is executing without errors but the answers I am expecting after the scalar multiplication is not correct according to NIST test vectors.

Input Values are(Already in the code):

ecc_160_a[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFC};

ecc_160_b[]={0x1C,0x97,0xBE,0xFC,0x54,0xBD,0x7A,0x8B,0x65,0xAC,0xF8,0x9F,0x81,0xD4,0xD4,0xAD,0xC5,0x65,0xFA,0x45};

ecc_160_p[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF};

ecc_160_n[]={0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF4,0xC8,0xF9,0x27,0xAE,0xD3,0xCA,0x75,0x22,0x57};

ecc_160_xG[]={0x4A,0x96,0xB5,0x68,0x8E,0xF5,0x73,0x28,0x46,0x64,0x69,0x89,0x68,0xC3,0x8B,0xB9,0x13,0xCB,0xFC,0x82};

ecc_160_yG[]={0x23,0xA6,0x28,0x55,0x31,0x68,0x94,0x7D,0x59,0xDC,0xC9,0x12,0x04,0x23,0x51,0x37,0x7A,0xC5,0xFB,0x32};

ecc_160_privkey[]={0xAA,0x37,0x4F,0xFC,0x3C,0xE1,0x44,0xE6,0xB0,0x73,0x30,0x79,0x72,0xCB,0x6D,0x57,0xB2,0xA4,0xE9,0x82};

Answer Should be:

X-Coordinate (decimal) =

466448783855397898016055842232266600516272889280

Y-Coordinate (decimal)=

1110706324081757720403272427311003102474457754220

Hex of X-Coordinate = 51B4496FECC406ED0E75A24A3C03206251419DC0

But is am getting wrong answers.

L

For X coordinate I am getting some value but for Y-Coordinate its all zeros except 0x55 and 0xAB in two bytes.

Also the returned size of X and Y coordinates is half of the original that is 10 bytes instead of 20 bytes

ecc.h file is attached.

Please Help.

Best Regards,

Ibrahim

________________

Attachments :

ecc.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1BN&d=%2Fa%2F0X0000000bkP%2Fodq5r23qUzwb03VksLmiuPzpZ0STNt4qKicJNU0mkl8&asPdf=false
Posted on July 23, 2014 at 04:13

Are you sure you have an adequate stack allocation?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 23, 2014 at 06:26

Success? Xsize 20, Ysize 20
X : 51B4496FECC406ED0E75A24A3C03206251419DC0
Y : C28DCB4B73A514B468D793894F381CCC1756AA6C

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 24, 2014 at 04:16

You need to initialize the ST Library

...
membuf_stt mb;
uint8_t preallocated_buffer[4096];
/* DeInitialize STM32 Cryptographic Library */
Crypto_DeInit();
//Set up the membuf_stt structure to a preallocated (on stack) buffer of 4kB
mb.mSize = sizeof(preallocated_buffer);
mb.mUsed = 0;
mb.pmBuf = preallocated_buffer;
...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..