Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
ecl_curve.c File Reference
#include "ecl.h"
#include "ecl-curve.h"
#include "ecl-priv.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Defines

#define CHECK(func)   if ((func) == NULL) { res = 0; goto CLEANUP; }

Functions

ECCurveParams * ECCurveParams_dup (const ECCurveParams *params)
ECCurveParams * EC_GetNamedCurveParams (const ECCurveName name)
void EC_FreeCurveParams (ECCurveParams *params)

Define Documentation

#define CHECK (   func)    if ((func) == NULL) { res = 0; goto CLEANUP; }

Definition at line 45 of file ecl_curve.c.


Function Documentation

void EC_FreeCurveParams ( ECCurveParams *  params)

Definition at line 104 of file ecl_curve.c.

{
       if (params == NULL)
              return;
       if (params->text != NULL)
              free(params->text);
       if (params->irr != NULL)
              free(params->irr);
       if (params->curvea != NULL)
              free(params->curvea);
       if (params->curveb != NULL)
              free(params->curveb);
       if (params->genx != NULL)
              free(params->genx);
       if (params->geny != NULL)
              free(params->geny);
       if (params->order != NULL)
              free(params->order);
       free(params);
}
ECCurveParams* EC_GetNamedCurveParams ( const ECCurveName  name)

Definition at line 92 of file ecl_curve.c.

{
       if ((name <= ECCurve_noName) || (ECCurve_pastLastCurve <= name) ||
                                   (ecCurve_map[name] == NULL)) {
              return NULL;
       } else {
              return ECCurveParams_dup(ecCurve_map[name]);
       }
}
ECCurveParams* ECCurveParams_dup ( const ECCurveParams *  params)

Definition at line 49 of file ecl_curve.c.

{
       int res = 1;
       ECCurveParams *ret = NULL;

       CHECK(ret = (ECCurveParams *) calloc(1, sizeof(ECCurveParams)));
       if (params->text != NULL) {
              CHECK(ret->text = strdup(params->text));
       }
       ret->field = params->field;
       ret->size = params->size;
       if (params->irr != NULL) {
              CHECK(ret->irr = strdup(params->irr));
       }
       if (params->curvea != NULL) {
              CHECK(ret->curvea = strdup(params->curvea));
       }
       if (params->curveb != NULL) {
              CHECK(ret->curveb = strdup(params->curveb));
       }
       if (params->genx != NULL) {
              CHECK(ret->genx = strdup(params->genx));
       }
       if (params->geny != NULL) {
              CHECK(ret->geny = strdup(params->geny));
       }
       if (params->order != NULL) {
              CHECK(ret->order = strdup(params->order));
       }
       ret->cofactor = params->cofactor;

  CLEANUP:
       if (res != 1) {
              EC_FreeCurveParams(ret);
              return NULL;
       }
       return ret;
}