Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
pqgutil.c File Reference
#include "pqgutil.h"
#include "prerror.h"
#include "secitem.h"

Go to the source code of this file.

Defines

#define PQG_DEFAULT_CHUNKSIZE   2048 /* bytes */

Functions

PQGParams * PQG_DupParams (const PQGParams *src)
PQGParams * PQG_NewParams (const SECItem *prime, const SECItem *subPrime, const SECItem *base)
SECStatus PQG_GetPrimeFromParams (const PQGParams *params, SECItem *prime)
SECStatus PQG_GetSubPrimeFromParams (const PQGParams *params, SECItem *subPrime)
SECStatus PQG_GetBaseFromParams (const PQGParams *params, SECItem *base)
void PQG_DestroyParams (PQGParams *params)
PQGVerify * PQG_DupVerify (const PQGVerify *src)
PQGVerify * PQG_NewVerify (unsigned int counter, const SECItem *seed, const SECItem *h)
unsigned int PQG_GetCounterFromVerify (const PQGVerify *verify)
SECStatus PQG_GetSeedFromVerify (const PQGVerify *verify, SECItem *seed)
SECStatus PQG_GetHFromVerify (const PQGVerify *verify, SECItem *h)
void PQG_DestroyVerify (PQGVerify *vfy)

Define Documentation

Definition at line 40 of file pqgutil.c.


Function Documentation

void PQG_DestroyParams ( PQGParams *  params)

Definition at line 146 of file pqgutil.c.

{
    if (params == NULL) 
       return;
    if (params->arena != NULL) {
       PORT_FreeArena(params->arena, PR_FALSE);  /* don't zero it */
    } else {
       SECITEM_FreeItem(&params->prime,    PR_FALSE); /* don't free prime */
       SECITEM_FreeItem(&params->subPrime, PR_FALSE); /* don't free subPrime */
       SECITEM_FreeItem(&params->base,     PR_FALSE); /* don't free base */
       PORT_Free(params);
    }
}

Here is the call graph for this function:

void PQG_DestroyVerify ( PQGVerify *  vfy)

Definition at line 259 of file pqgutil.c.

{
    if (vfy == NULL) 
       return;
    if (vfy->arena != NULL) {
       PORT_FreeArena(vfy->arena, PR_FALSE);     /* don't zero it */
    } else {
       SECITEM_FreeItem(&vfy->seed,   PR_FALSE); /* don't free seed */
       SECITEM_FreeItem(&vfy->h,      PR_FALSE); /* don't free h */
       PORT_Free(vfy);
    }
}

Here is the call graph for this function:

PQGParams* PQG_DupParams ( const PQGParams *  src)

Definition at line 50 of file pqgutil.c.

{
    PRArenaPool *arena;
    PQGParams *dest;
    SECStatus status;

    if (src == NULL) {
       PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
       return NULL;
    }

    arena = PORT_NewArena(PQG_DEFAULT_CHUNKSIZE);
    if (arena == NULL)
       goto loser;

    dest = (PQGParams*)PORT_ArenaZAlloc(arena, sizeof(PQGParams));
    if (dest == NULL)
       goto loser;

    dest->arena = arena;

    status = SECITEM_CopyItem(arena, &dest->prime, &src->prime);
    if (status != SECSuccess)
       goto loser;

    status = SECITEM_CopyItem(arena, &dest->subPrime, &src->subPrime);
    if (status != SECSuccess)
       goto loser;

    status = SECITEM_CopyItem(arena, &dest->base, &src->base);
    if (status != SECSuccess)
       goto loser;

    return dest;

loser:
    if (arena != NULL)
       PORT_FreeArena(arena, PR_FALSE);
    return NULL;
}

Here is the call graph for this function:

PQGVerify* PQG_DupVerify ( const PQGVerify *  src)

Definition at line 167 of file pqgutil.c.

{
    PRArenaPool *arena;
    PQGVerify *  dest;
    SECStatus    status;

    if (src == NULL) {
       PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
       return NULL;
    }

    arena = PORT_NewArena(PQG_DEFAULT_CHUNKSIZE);
    if (arena == NULL)
       goto loser;

    dest = (PQGVerify*)PORT_ArenaZAlloc(arena, sizeof(PQGVerify));
    if (dest == NULL)
       goto loser;

    dest->arena   = arena;
    dest->counter = src->counter;

    status = SECITEM_CopyItem(arena, &dest->seed, &src->seed);
    if (status != SECSuccess)
       goto loser;

    status = SECITEM_CopyItem(arena, &dest->h, &src->h);
    if (status != SECSuccess)
       goto loser;

    return dest;

loser:
    if (arena != NULL)
       PORT_FreeArena(arena, PR_FALSE);
    return NULL;
}

Here is the call graph for this function:

SECStatus PQG_GetBaseFromParams ( const PQGParams *  params,
SECItem *  base 
)

Definition at line 137 of file pqgutil.c.

{
    return SECITEM_CopyItem(NULL, base, &params->base);
}

Here is the call graph for this function:

unsigned int PQG_GetCounterFromVerify ( const PQGVerify *  verify)

Definition at line 229 of file pqgutil.c.

{
    return verify->counter;
}
SECStatus PQG_GetHFromVerify ( const PQGVerify *  verify,
SECItem *  h 
)

Definition at line 249 of file pqgutil.c.

{
    return SECITEM_CopyItem(NULL, h, &verify->h);
}

Here is the call graph for this function:

SECStatus PQG_GetPrimeFromParams ( const PQGParams *  params,
SECItem *  prime 
)

Definition at line 117 of file pqgutil.c.

{
    return SECITEM_CopyItem(NULL, prime, &params->prime);
}

Here is the call graph for this function:

SECStatus PQG_GetSeedFromVerify ( const PQGVerify *  verify,
SECItem *  seed 
)

Definition at line 239 of file pqgutil.c.

{
    return SECITEM_CopyItem(NULL, seed, &verify->seed);
}

Here is the call graph for this function:

SECStatus PQG_GetSubPrimeFromParams ( const PQGParams *  params,
SECItem *  subPrime 
)

Definition at line 127 of file pqgutil.c.

{
    return SECITEM_CopyItem(NULL, subPrime, &params->subPrime);
}

Here is the call graph for this function:

PQGParams* PQG_NewParams ( const SECItem *  prime,
const SECItem *  subPrime,
const SECItem *  base 
)

Definition at line 98 of file pqgutil.c.

{
    PQGParams *  dest;
    PQGParams    src;

    src.arena    = NULL;
    src.prime    = *prime;
    src.subPrime = *subPrime;
    src.base     = *base;
    dest         = PQG_DupParams(&src);
    return dest;
}

Here is the call graph for this function:

PQGVerify* PQG_NewVerify ( unsigned int  counter,
const SECItem *  seed,
const SECItem *  h 
)

Definition at line 212 of file pqgutil.c.

{
    PQGVerify *  dest;
    PQGVerify    src;

    src.arena    = NULL;
    src.counter  = counter;
    src.seed     = *seed;
    src.h        = *h;
    dest         = PQG_DupVerify(&src);
    return dest;
}

Here is the call graph for this function: