/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __JAR_h_ #define __JAR_h_
/* * In general, any functions that return pointers * have memory owned by the caller. *
*/
/* security includes */ #include"cert.h" #include"hasht.h"
/* jar object */ typedefstruct JAR_ {
jarArch format; /* physical archive format */
char *url; /* Where it came from */ char *filename; /* Disk location */
FILE *fp; /* For multiple extractions */ /* JAR_FILE */
/* various linked lists */
ZZList *manifest; /* Digests of MF sections */
ZZList *hashes; /* Digests of actual signed files */
ZZList *phy; /* Physical layout of JAR file */
ZZList *metainfo; /* Global metainfo */
JAR_Digest *globalmeta; /* digest of .MF global portion */
/* Below will change to a linked list to support multiple sigs */ int pkcs7; /* Enforced opaqueness */ int valid; /* PKCS7 signature validated */
ZZList *signers; /* the above, per signer */
/* Window context, very necessary for PKCS11 now */ void *mw; /* MWContext window context */
/* Signal callback function */
jar_settable_callback_fn *signal;
} JAR;
/* * Iterator * * Context for iterative operations. Certain operations * require iterating multiple linked lists because of * multiple signers. "nextsign" is used for this purpose. *
*/ typedefstruct JAR_Context_ {
JAR *jar; /* Jar we are searching */ char *pattern; /* Regular expression */
jarType finding; /* Type of item to find */
ZZLink *next; /* Next item in find */
ZZLink *nextsign; /* Next signer, sometimes */
} JAR_Context;
typedefstruct JAR_Signer_ { int pkcs7; /* Enforced opaqueness */ int valid; /* PKCS7 signature validated */ char *owner; /* name of .RSA file */
JAR_Digest *digest; /* of .SF file */
ZZList *sf; /* Linked list of .SF file contents */
ZZList *certs; /* Signing information */
} JAR_Signer;
/* Meta informaton, or "policy", from the manifest file.
Right now just one tuple per JAR_Item. */ typedefstruct JAR_Metainfo_ { char *header; char *info;
} JAR_Metainfo;
/* This should not be global */ typedefstruct JAR_Physical_ { unsignedchar compression; unsignedlong offset; unsignedlong length; unsignedlong uncompressed_length; #ifdefined(XP_UNIX)
PRUint16 mode; #endif
} JAR_Physical;
/* * This is the base for the JAR error codes. It will * change when these are incorporated into allxpstr.c, * but right now they won't let me put them there. *
*/ #ifndef SEC_ERR_BASE #define SEC_ERR_BASE (-0x2000) #endif
/* * JAR_set_context * * PKCS11 may require a password to be entered by the user * before any crypto routines may be called. This will require * a window context if used from inside Mozilla. * * Call this routine with your context before calling * verifying or signing. If you have no context, call with NULL * and one will be chosen for you. *
*/ int JAR_set_context(JAR *jar, void/*MWContext*/ *mw);
/* * Iterative operations * * JAR_find sets up for repeated calls with JAR_find_next. * I never liked findfirst and findnext, this is nicer. * * Pattern contains a relative pathname to match inside the * archive. It is currently assumed to be "*". * * To use: * * JAR_Item *item; * JAR_find (jar, "*.class", jarTypeMF); * while (JAR_find_next (jar, &item) >= 0) * { do stuff } *
*/
/* Replacement functions with an external context */
/* * Function to parse manifest file: * * Many signatures may be attached to a single filename located * inside the zip file. We only support one. * * Several manifests may be included in the zip file. * * You must pass the MANIFEST.MF file before any .SF files. * * Right now this returns a big ole list, privately in the jar structure. * If you need to traverse it, use JAR_find if possible. * * The path is needed to determine what type of binary signature is * being passed, though it is technically not needed for manifest files. * * When parsing an ASCII file, null terminate the ASCII raw_manifest * prior to sending it, and indicate a length of 0. For binary digital * signatures only, indicate the true length of the signature. * (This is legacy behavior.) * * You may free the manifest after parsing it. *
*/
/* * Meta information * * Currently, since this call does not support passing of an owner * (certificate, or physical name of the .sf file), it is restricted to * returning information located in the manifest.mf file. * * Meta information is a name/value pair inside the archive file. Here, * the name is passed in *header and value returned in **info. * * Pass a NULL as the name to retrieve metainfo from the global section. * * Data is returned in **info, of size *length. The return value * will indicate if no data was found. *
*/
/* save the certificate with this fingerprint in persistent storage, somewhere, for retrieval in a future session when there
is no corresponding JAR structure. */ externint PR_CALLBACK
JAR_stash_cert(JAR *jar, long keylen, void *key);
/* retrieve a certificate presumably stashed with the above
function, but may be any certificate. Type is &CERTCertificate */
CERTCertificate *
JAR_fetch_cert(long length, void *key);
/* * New functions to handle archives alone * (call JAR_new beforehand) * * JAR_pass_archive acts much like parse_manifest. Certificates * are returned in the JAR structure but as opaque data. When calling * JAR_verified_extract you still need to decide which of these * certificates to honor. * * Code to examine a JAR structure is in jarbert.c. You can obtain both * a list of filenames and certificates from traversing the linked list. *
*/ externint
JAR_pass_archive(JAR *jar, jarArch format, char *filename, constchar *url);
/* * Same thing, but don't check signatures
*/ externint
JAR_pass_archive_unverified(JAR *jar, jarArch format, char *filename, constchar *url);
/* * Extracts a relative pathname from the archive and places it * in the filename specified. * * Call JAR_set_nailed if you want to keep the file descriptors * open between multiple calls to JAR_verify_extract. *
*/ externint
JAR_verified_extract(JAR *jar, char *path, char *outpath);
/* * JAR_extract does no crypto checking. This can be used if you * need to extract a manifest file or signature, etc. *
*/ externint
JAR_extract(JAR *jar, char *path, char *outpath);
#endif/* __JAR_h_ */
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.