Back to index

lightning-sunbird  0.9+nobinonly
Functions
jarjart.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * JAR_JAR_list_certs (void)
int JAR_JAR_validate_archive (char *filename)
voidJAR_JAR_new_hash (int alg)
voidJAR_JAR_hash (int alg, void *cookie, int length, void *data)
voidJAR_JAR_end_hash (int alg, void *cookie)
int JAR_JAR_sign_archive (char *nickname, char *password, char *sf, char *outsig)
char * JAR_JAR_get_error (int status)

Function Documentation

void* JAR_JAR_end_hash ( int  alg,
void cookie 
)

Definition at line 247 of file jarjart.c.

  {
  int length;
  unsigned char *data;
  char *ascii; 

  MD5Context *md5;
  SHA1Context *sha1;

  unsigned int md5_length;
  unsigned char md5_digest [MD5_LENGTH];

  unsigned int sha1_length;
  unsigned char sha1_digest [SHA1_LENGTH];

  /* this is a hack because this whole PORT_ZAlloc stuff looks scary */

  if (!PK11_HashOK (alg == 1 ? SEC_OID_MD5 : SEC_OID_SHA1)) 
    return NULL;

  switch (alg)
    {
    case 1:  /* MD5 */

             md5 = (MD5Context *) cookie;

             MD5_End (md5, md5_digest, &md5_length, MD5_LENGTH);
             /* MD5_DestroyContext (md5, PR_TRUE); */

             data = md5_digest;
             length = md5_length;

             break;

    case 2:  /* SHA1 */

             sha1 = (SHA1Context *) cookie;

             SHA1_End (sha1, sha1_digest, &sha1_length, SHA1_LENGTH);
             /* SHA1_DestroyContext (sha1, PR_TRUE); */

             data = sha1_digest;
             length = sha1_length;

             break;

    default: return NULL;
    }

  /* Instead of destroy context, since we created it */
  /* PORT_Free (cookie); */

  ascii = BTOA_DataToAscii(data, length);

  return ascii ? PORT_Strdup (ascii) : NULL;
  }

Here is the call graph for this function:

char* JAR_JAR_get_error ( int  status)

Definition at line 164 of file jarjart.c.

  {
  return JAR_get_error (status);
  }

Here is the call graph for this function:

void* JAR_JAR_hash ( int  alg,
void cookie,
int  length,
void data 
)

Definition at line 218 of file jarjart.c.

  {
  MD5Context *md5;
  SHA1Context *sha1;

  /* this is a hack because this whole PORT_ZAlloc stuff looks scary */

  if (!PK11_HashOK (alg == 1 ? SEC_OID_MD5 : SEC_OID_SHA1))
    return NULL;

  if (length > 0)
    {
    switch (alg)
      {
      case 1:  /* MD5 */
               md5 = (MD5Context *) cookie;
               MD5_Update (md5, (unsigned char*)data, length);
               break;

      case 2:  /* SHA1 */
               sha1 = (SHA1Context *) cookie;
               SHA1_Update (sha1, (unsigned char*)data, length);
               break;
      }
    }

  return cookie;
  }

Here is the call graph for this function:

char* JAR_JAR_list_certs ( void  )

Definition at line 108 of file jarjart.c.

  {
  SECStatus status = SECFailure;
  CERTCertDBHandle *certdb;
  CERTCertList *certs;
  CERTCertListNode *node;

  char *ugly_list;

  certdb = JAR_open_database();

  /* a little something */
  ugly_list = (char*)PORT_ZAlloc (16);

  if (ugly_list)
    {
    *ugly_list = 0;

    certs = PK11_ListCerts(PK11CertListUnique, NULL/* pwarg*/);
    if (certs)
      {
       for (node = CERT_LIST_HEAD(certs); !CERT_LIST_END(node,certs);
                            node = CERT_LIST_NEXT(node))
           {
           jar_list_cert_callback(node->cert, NULL, (void *)&ugly_list);
          }
       CERT_DestroyCertList(certs);
       status = SECSuccess;
       }
    }

  JAR_close_database (certdb);

  return (status != SECSuccess) ? NULL : ugly_list;
  }

Here is the call graph for this function:

Definition at line 185 of file jarjart.c.

  {
  void *context;

  MD5Context *md5;
  SHA1Context *sha1;

  /* this is a hack because this whole PORT_ZAlloc stuff looks scary */

  if (!PK11_HashOK (alg == 1 ? SEC_OID_MD5 : SEC_OID_SHA1))
    return NULL;

  context = PORT_ZAlloc (512);

  if (context)
    {
    switch (alg)
      {
      case 1:  /* MD5 */
               md5 = (MD5Context *) context;
               MD5_Begin (md5);
               break;

      case 2:  /* SHA1 */
               sha1 = (SHA1Context *) context;
               SHA1_Begin (sha1);
               break;
      }
    }

  return context;
  }

Here is the call graph for this function:

int JAR_JAR_sign_archive ( char *  nickname,
char *  password,
char *  sf,
char *  outsig 
)

Definition at line 312 of file jarjart.c.

  {
  char *out_fn;

  int status = JAR_ERR_GENERAL;
  JAR_FILE sf_fp; 
  JAR_FILE out_fp;

  CERTCertDBHandle *certdb;
  void *keydb;

  CERTCertificate *cert;

  /* open cert and key databases */

  certdb = JAR_open_database();
  if (certdb == NULL)
    return JAR_ERR_GENERAL;

  keydb = jar_open_key_database();
  if (keydb == NULL)
    return JAR_ERR_GENERAL;

  out_fn = PORT_Strdup (sf);

  if (out_fn == NULL || PORT_Strlen (sf) < 5)
    return JAR_ERR_GENERAL;

  sf_fp = JAR_FOPEN (sf, "rb");
  out_fp = JAR_FOPEN (outsig, "wb");

  cert = CERT_FindCertByNickname (certdb, nickname);

  if (cert && sf_fp && out_fp)
    {
    status = jar_create_pk7 (certdb, keydb, cert, password, sf_fp, out_fp);
    }

  /* remove password from prying eyes */
  PORT_Memset (password, 0, PORT_Strlen (password));

  JAR_FCLOSE (sf_fp);
  JAR_FCLOSE (out_fp);

  JAR_close_database (certdb);
  jar_close_key_database (keydb);

  return status;
  }

Here is the call graph for this function:

int JAR_JAR_validate_archive ( char *  filename)

Definition at line 144 of file jarjart.c.

  {
  JAR *jar;
  int status = -1;

  jar = JAR_new();

  if (jar)
    {
    status = JAR_pass_archive (jar, jarArchGuess, filename, "");

    if (status == 0)
      status = jar->valid;

    JAR_destroy (jar);
    }

  return status;
  }

Here is the call graph for this function: