Back to index

lightning-sunbird  0.9+nobinonly
secdig.h
Go to the documentation of this file.
00001 /*
00002  * crypto.h - public data structures and prototypes for the crypto library
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is the Netscape security libraries.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 /* $Id: secdig.h,v 1.5 2004/04/27 23:04:40 gerv%gerv.net Exp $ */
00040 
00041 #ifndef _SECDIG_H_
00042 #define _SECDIG_H_
00043 
00044 #include "secdigt.h"
00045 
00046 #include "seccomon.h"
00047 #include "secasn1t.h" 
00048 #include "secdert.h"
00049 
00050 SEC_BEGIN_PROTOS
00051 
00052 
00053 extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
00054 
00055 SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
00056 
00057 extern DERTemplate SGNDigestInfoTemplate[];
00058 
00059 
00060 /****************************************/
00061 /*
00062 ** Digest-info functions
00063 */
00064 
00065 /*
00066 ** Create a new digest-info object
00067 **     "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
00068 **     "sig" the raw signature data (from MD2 or MD5)
00069 **     "sigLen" the length of the signature data
00070 **
00071 ** NOTE: this is a low level routine used to prepare some data for PKCS#1
00072 ** digital signature formatting.
00073 **
00074 ** XXX It might be nice to combine the create and encode functions.
00075 ** I think that is all anybody ever wants to do anyway.
00076 */
00077 extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
00078                                       unsigned char *sig,
00079                                       unsigned int sigLen);
00080 
00081 /*
00082 ** Destroy a digest-info object
00083 */
00084 extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
00085 
00086 /*
00087 ** Encode a digest-info object
00088 **     "poolp" is where to allocate the result from; it can be NULL in
00089 **            which case generic heap allocation (XP_ALLOC) will be used
00090 **     "dest" is where to store the result; it can be NULL, in which case
00091 **            it will be allocated (from poolp or heap, as explained above)
00092 **     "diginfo" is the object to be encoded
00093 ** The return value is NULL if any error occurred, otherwise it is the
00094 ** resulting SECItem (either allocated or the same as the "dest" parameter).
00095 **
00096 ** XXX It might be nice to combine the create and encode functions.
00097 ** I think that is all anybody ever wants to do anyway.
00098 */
00099 extern SECItem *SGN_EncodeDigestInfo(PRArenaPool *poolp, SECItem *dest,
00100                                  SGNDigestInfo *diginfo);
00101 
00102 /*
00103 ** Decode a DER encoded digest info objct.
00104 **  didata is thr source of the encoded digest.  
00105 ** The return value is NULL if an error occurs.  Otherwise, a
00106 ** digest info object which is allocated within it's own
00107 ** pool is returned.  The digest info should be deleted
00108 ** by later calling SGN_DestroyDigestInfo.
00109 */
00110 extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
00111 
00112 
00113 /*
00114 ** Copy digest info.
00115 **  poolp is the arena to which the digest will be copied.
00116 **  a is the destination digest, it must be non-NULL.
00117 **  b is the source digest
00118 ** This function is for copying digests.  It allows digests
00119 ** to be copied into a specified pool.  If the digest is in
00120 ** the same pool as other data, you do not want to delete
00121 ** the digest by calling SGN_DestroyDigestInfo.  
00122 ** A return value of SECFailure indicates an error.  A return
00123 ** of SECSuccess indicates no error occured.
00124 */
00125 extern SECStatus  SGN_CopyDigestInfo(PRArenaPool *poolp,
00126                                    SGNDigestInfo *a, 
00127                                    SGNDigestInfo *b);
00128 
00129 /*
00130 ** Compare two digest-info objects, returning the difference between
00131 ** them.
00132 */
00133 extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
00134 
00135 
00136 SEC_END_PROTOS
00137 
00138 #endif /* _SECDIG_H_ */