F
F
flixli2018-05-20 13:57:57
Cryptography
flixli, 2018-05-20 13:57:57

Exception in the program, how to fix it?

I am writing a program that simulates the generation of a shared key using isogenies of elliptic curves. Isogenies are fully implemented in the Microsoft library, the program only calls ready-made functions of this library. When executing the program, an exception "access violation while executing at address 0x00000000" occurs in the highlighted line. What could be wrong?
Program text:

struct KeysStruct {
  unsigned char *PrivateKey;
  unsigned char *PublicKey;
} KeysA, KeysB;
int main()
{
  /*Инициализация эллиптической кривой*/

  PCurveIsogenyStruct CurveIsogeny = { 0 };
  extern CurveIsogenyStaticData CurveIsogeny_SIDHp751;
  CurveIsogenyStaticData *PCurveData;
  PCurveData = &CurveIsogeny_SIDHp751;
  CurveIsogeny = SIDH_curve_allocate(PCurveData);
  CRYPTO_STATUS Status = CRYPTO_SUCCESS;
  if (CurveIsogeny == NULL)
  {
    printf("not work");
    sleep(SEC);
    return 0;
  }
  Status = SIDH_curve_initialize(CurveIsogeny, CurveIsogeny->RandomBytesFunction, PCurveData);
  if (Status != CRYPTO_SUCCESS)
  {
    printf("not work");
    sleep(SEC);
    return 0;
  }

  /*Генерация ключа Алисы*/

  unsigned int i, pbytes = (PCurveData->pwordbits + 7) / 8;
  unsigned int obytes = (PCurveData->owordbits + 7) / 8;
  Status = CRYPTO_SUCCESS;
  bool ok = true;
  srand(time(NULL));
  KeysA.PrivateKey = (unsigned char*)calloc(1, obytes);
  KeysA.PublicKey = (unsigned char*)calloc(1, 4 * 2 * pbytes);

Status = EphemeralKeyGeneration_A(KeysA.PrivateKey, KeysA.PublicKey, CurveIsogeny);

  if (Status != CRYPTO_SUCCESS)
    ok = false;
  printf("work");
  sleep(SEC);
    return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2018-05-20
@flixli

Status = SIDH_curve_initialize(CurveIsogeny, CurveIsogeny->RandomBytesFunction, PCurveData);

Here you are initializing CurveIsogeny , and in doing so you are passing CurveIsogeny->RandomBytesFunction , which is NULL at the time the initialization function is called. You have to give it an external function that generates random values. And it will just be placed in CurveIsogeny->RandomBytesFunction .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question