Back to index

lightning-sunbird  0.9+nobinonly
padbuf.c File Reference
#include "blapit.h"
#include "secport.h"
#include "secerr.h"

Go to the source code of this file.


unsigned char * DES_PadBuffer (PRArenaPool *arena, unsigned char *inbuf, unsigned int inlen, unsigned int *outlen)

Function Documentation

unsigned char* DES_PadBuffer ( PRArenaPool arena,
unsigned char *  inbuf,
unsigned int  inlen,
unsigned int outlen 

Definition at line 48 of file padbuf.c.

    unsigned char *outbuf;
    unsigned int   des_len;
    unsigned int   i;
    unsigned char  des_pad_len;

     * We need from 1 to DES_KEY_LENGTH bytes -- we *always* grow.
     * The extra bytes contain the value of the length of the padding:
     * if we have 2 bytes of padding, then the padding is "0x02, 0x02".
    des_len = (inlen + DES_KEY_LENGTH) & ~(DES_KEY_LENGTH - 1);

    if (arena != NULL) {
       outbuf = (unsigned char*)PORT_ArenaGrow (arena, inbuf, inlen, des_len);
    } else {
       outbuf = (unsigned char*)PORT_Realloc (inbuf, des_len);

    if (outbuf == NULL) {
       return NULL;

    des_pad_len = des_len - inlen;
    for (i = inlen; i < des_len; i++)
       outbuf[i] = des_pad_len;

    *outlen = des_len;
    return outbuf;

Here is the caller graph for this function: