Back to index

lightning-sunbird  0.9+nobinonly
Functions
nssb64.h File Reference
#include "seccomon.h"
#include "nssb64t.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

SEC_BEGIN_PROTOS NSSBase64Decoder * NSSBase64Decoder_Create (PRInt32(*output_fn)(void *, const unsigned char *, PRInt32), void *output_arg)
NSSBase64Encoder * NSSBase64Encoder_Create (PRInt32(*output_fn)(void *, const char *, PRInt32), void *output_arg)
SECStatus NSSBase64Decoder_Update (NSSBase64Decoder *data, const char *buffer, PRUint32 size)
SECStatus NSSBase64Encoder_Update (NSSBase64Encoder *data, const unsigned char *buffer, PRUint32 size)
SECStatus NSSBase64Decoder_Destroy (NSSBase64Decoder *data, PRBool abort_p)
SECStatus NSSBase64Encoder_Destroy (NSSBase64Encoder *data, PRBool abort_p)
SECItem * NSSBase64_DecodeBuffer (PRArenaPool *arenaOpt, SECItem *outItemOpt, const char *inStr, unsigned int inLen)
char * NSSBase64_EncodeItem (PRArenaPool *arenaOpt, char *outStrOpt, unsigned int maxOutLen, SECItem *inItem)

Function Documentation

SECItem* NSSBase64_DecodeBuffer ( PRArenaPool arenaOpt,
SECItem *  outItemOpt,
const char *  inStr,
unsigned int  inLen 
)

Definition at line 747 of file nssb64d.c.

{
    SECItem *out_item = outItemOpt;
    PRUint32 max_out_len = PL_Base64MaxDecodedLength (inLen);
    PRUint32 out_len;
    void *mark = NULL;
    unsigned char *dummy;

    PORT_Assert(outItemOpt == NULL || outItemOpt->data == NULL);

    if (arenaOpt != NULL)
       mark = PORT_ArenaMark (arenaOpt);

    out_item = SECITEM_AllocItem (arenaOpt, outItemOpt, max_out_len);
    if (out_item == NULL) {
       if (arenaOpt != NULL)
           PORT_ArenaRelease (arenaOpt, mark);
       return NULL;
    }

    dummy = PL_Base64DecodeBuffer (inStr, inLen, out_item->data,
                               max_out_len, &out_len);
    if (dummy == NULL) {
       if (arenaOpt != NULL) {
           PORT_ArenaRelease (arenaOpt, mark);
           if (outItemOpt != NULL) {
              outItemOpt->data = NULL;
              outItemOpt->len = 0;
           }
       } else {
           SECITEM_FreeItem (out_item,
                           (outItemOpt == NULL) ? PR_TRUE : PR_FALSE);
       }
       return NULL;
    }

    if (arenaOpt != NULL)
       PORT_ArenaUnmark (arenaOpt, mark);
    out_item->len = out_len;
    return out_item;
}

Here is the caller graph for this function:

char* NSSBase64_EncodeItem ( PRArenaPool arenaOpt,
char *  outStrOpt,
unsigned int  maxOutLen,
SECItem *  inItem 
)

Definition at line 664 of file nssb64e.c.

{
    char *out_string = outStrOpt;
    PRUint32 max_out_len;
    PRUint32 out_len;
    void *mark = NULL;
    char *dummy;

    PORT_Assert(inItem != NULL && inItem->data != NULL && inItem->len != 0);
    if (inItem == NULL || inItem->data == NULL || inItem->len == 0) {
       PORT_SetError (SEC_ERROR_INVALID_ARGS);
       return NULL;
    }

    max_out_len = PL_Base64MaxEncodedLength (inItem->len, 64);

    if (arenaOpt != NULL)
       mark = PORT_ArenaMark (arenaOpt);

    if (out_string == NULL) {
       if (arenaOpt != NULL)
           out_string = PORT_ArenaAlloc (arenaOpt, max_out_len + 1);
       else
           out_string = PORT_Alloc (max_out_len + 1);

       if (out_string == NULL) {
           if (arenaOpt != NULL)
              PORT_ArenaRelease (arenaOpt, mark);
           return NULL;
       }
    } else {
       if ((max_out_len + 1) > maxOutLen) {
           PORT_SetError (SEC_ERROR_OUTPUT_LEN);
           return NULL;
       }
       max_out_len = maxOutLen;
    }


    dummy = PL_Base64EncodeBuffer (inItem->data, inItem->len, 64,
                               out_string, max_out_len, &out_len);
    if (dummy == NULL) {
       if (arenaOpt != NULL) {
           PORT_ArenaRelease (arenaOpt, mark);
       } else {
           PORT_Free (out_string);
       }
       return NULL;
    }

    if (arenaOpt != NULL)
       PORT_ArenaUnmark (arenaOpt, mark);

    out_string[out_len] = '\0';
    return out_string;
}

Here is the caller graph for this function:

SEC_BEGIN_PROTOS NSSBase64Decoder* NSSBase64Decoder_Create ( PRInt32(*)(void *, const unsigned char *, PRInt32 output_fn,
void output_arg 
)

Definition at line 660 of file nssb64d.c.

{
    PLBase64Decoder *pl_data;
    NSSBase64Decoder *nss_data;

    nss_data = PORT_ZNew(NSSBase64Decoder);
    if (nss_data == NULL)
       return NULL;

    pl_data = PL_CreateBase64Decoder (output_fn, output_arg);
    if (pl_data == NULL) {
       PORT_Free(nss_data);
       return NULL;
    }

    nss_data->pl_data = pl_data;
    return nss_data;
}

Here is the caller graph for this function:

SECStatus NSSBase64Decoder_Destroy ( NSSBase64Decoder *  data,
PRBool  abort_p 
)

Definition at line 712 of file nssb64d.c.

{
    PRStatus pr_status;

    /* XXX Should we do argument checking only in debug build? */
    if (data == NULL) {
       PORT_SetError (SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    pr_status = PL_DestroyBase64Decoder (data->pl_data, abort_p);

    PORT_Free(data);

    if (pr_status == PR_FAILURE)
       return SECFailure;

    return SECSuccess;
}

Here is the caller graph for this function:

SECStatus NSSBase64Decoder_Update ( NSSBase64Decoder *  data,
const char *  buffer,
PRUint32  size 
)

Definition at line 687 of file nssb64d.c.

{
    PRStatus pr_status;

    /* XXX Should we do argument checking only in debug build? */
    if (data == NULL) {
       PORT_SetError (SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    pr_status = PL_UpdateBase64Decoder (data->pl_data, buffer, size);
    if (pr_status == PR_FAILURE)
       return SECFailure;

    return SECSuccess;
}

Here is the caller graph for this function:

NSSBase64Encoder* NSSBase64Encoder_Create ( PRInt32(*)(void *, const char *, PRInt32 output_fn,
void output_arg 
)

Definition at line 575 of file nssb64e.c.

{
    PLBase64Encoder *pl_data;
    NSSBase64Encoder *nss_data;

    nss_data = PORT_ZNew(NSSBase64Encoder);
    if (nss_data == NULL)
       return NULL;

    pl_data = PL_CreateBase64Encoder (output_fn, output_arg, 64);
    if (pl_data == NULL) {
       PORT_Free(nss_data);
       return NULL;
    }

    nss_data->pl_data = pl_data;
    return nss_data;
}

Here is the caller graph for this function:

SECStatus NSSBase64Encoder_Destroy ( NSSBase64Encoder *  data,
PRBool  abort_p 
)

Definition at line 626 of file nssb64e.c.

{
    PRStatus pr_status;

    /* XXX Should we do argument checking only in debug build? */
    if (data == NULL) {
       PORT_SetError (SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    pr_status = PL_DestroyBase64Encoder (data->pl_data, abort_p);

    PORT_Free(data);

    if (pr_status == PR_FAILURE)
       return SECFailure;

    return SECSuccess;
}

Here is the caller graph for this function:

SECStatus NSSBase64Encoder_Update ( NSSBase64Encoder *  data,
const unsigned char *  buffer,
PRUint32  size 
)

Definition at line 601 of file nssb64e.c.

{
    PRStatus pr_status;

    /* XXX Should we do argument checking only in debug build? */
    if (data == NULL) {
       PORT_SetError (SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    pr_status = PL_UpdateBase64Encoder (data->pl_data, buffer, size);
    if (pr_status == PR_FAILURE)
       return SECFailure;

    return SECSuccess;
}

Here is the caller graph for this function: