PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/secdig.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 136 lines | 23 code | 18 blank | 95 comment | 0 complexity | 4b8c0c25917711c93012815ed131b764 MD5 | raw file
  1/*
  2 * crypto.h - public data structures and prototypes for the crypto library
  3 *
  4 * ***** BEGIN LICENSE BLOCK *****
  5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6 *
  7 * The contents of this file are subject to the Mozilla Public License Version
  8 * 1.1 (the "License"); you may not use this file except in compliance with
  9 * the License. You may obtain a copy of the License at
 10 * http://www.mozilla.org/MPL/
 11 *
 12 * Software distributed under the License is distributed on an "AS IS" basis,
 13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 14 * for the specific language governing rights and limitations under the
 15 * License.
 16 *
 17 * The Original Code is the Netscape security libraries.
 18 *
 19 * The Initial Developer of the Original Code is
 20 * Netscape Communications Corporation.
 21 * Portions created by the Initial Developer are Copyright (C) 1994-2000
 22 * the Initial Developer. All Rights Reserved.
 23 *
 24 * Contributor(s):
 25 *
 26 * Alternatively, the contents of this file may be used under the terms of
 27 * either the GNU General Public License Version 2 or later (the "GPL"), or
 28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 29 * in which case the provisions of the GPL or the LGPL are applicable instead
 30 * of those above. If you wish to allow use of your version of this file only
 31 * under the terms of either the GPL or the LGPL, and not to allow others to
 32 * use your version of this file under the terms of the MPL, indicate your
 33 * decision by deleting the provisions above and replace them with the notice
 34 * and other provisions required by the GPL or the LGPL. If you do not delete
 35 * the provisions above, a recipient may use your version of this file under
 36 * the terms of any one of the MPL, the GPL or the LGPL.
 37 *
 38 * ***** END LICENSE BLOCK ***** */
 39/* $Id: secdig.h,v 1.7 2007/11/07 02:37:22 julien.pierre.boogz%sun.com Exp $ */
 40
 41#ifndef _SECDIG_H_
 42#define _SECDIG_H_
 43
 44#include "utilrename.h"
 45#include "secdigt.h"
 46
 47#include "seccomon.h"
 48#include "secasn1t.h" 
 49#include "secdert.h"
 50
 51SEC_BEGIN_PROTOS
 52
 53
 54extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
 55
 56SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
 57
 58/****************************************/
 59/*
 60** Digest-info functions
 61*/
 62
 63/*
 64** Create a new digest-info object
 65** 	"algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
 66** 	"sig" the raw signature data (from MD2 or MD5)
 67** 	"sigLen" the length of the signature data
 68**
 69** NOTE: this is a low level routine used to prepare some data for PKCS#1
 70** digital signature formatting.
 71**
 72** XXX It might be nice to combine the create and encode functions.
 73** I think that is all anybody ever wants to do anyway.
 74*/
 75extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
 76					   unsigned char *sig,
 77					   unsigned int sigLen);
 78
 79/*
 80** Destroy a digest-info object
 81*/
 82extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
 83
 84/*
 85** Encode a digest-info object
 86**	"poolp" is where to allocate the result from; it can be NULL in
 87**		which case generic heap allocation (XP_ALLOC) will be used
 88**	"dest" is where to store the result; it can be NULL, in which case
 89**		it will be allocated (from poolp or heap, as explained above)
 90**	"diginfo" is the object to be encoded
 91** The return value is NULL if any error occurred, otherwise it is the
 92** resulting SECItem (either allocated or the same as the "dest" parameter).
 93**
 94** XXX It might be nice to combine the create and encode functions.
 95** I think that is all anybody ever wants to do anyway.
 96*/
 97extern SECItem *SGN_EncodeDigestInfo(PRArenaPool *poolp, SECItem *dest,
 98				     SGNDigestInfo *diginfo);
 99
100/*
101** Decode a DER encoded digest info objct.
102**  didata is thr source of the encoded digest.  
103** The return value is NULL if an error occurs.  Otherwise, a
104** digest info object which is allocated within it's own
105** pool is returned.  The digest info should be deleted
106** by later calling SGN_DestroyDigestInfo.
107*/
108extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
109
110
111/*
112** Copy digest info.
113**  poolp is the arena to which the digest will be copied.
114**  a is the destination digest, it must be non-NULL.
115**  b is the source digest
116** This function is for copying digests.  It allows digests
117** to be copied into a specified pool.  If the digest is in
118** the same pool as other data, you do not want to delete
119** the digest by calling SGN_DestroyDigestInfo.  
120** A return value of SECFailure indicates an error.  A return
121** of SECSuccess indicates no error occured.
122*/
123extern SECStatus  SGN_CopyDigestInfo(PRArenaPool *poolp,
124					SGNDigestInfo *a, 
125					SGNDigestInfo *b);
126
127/*
128** Compare two digest-info objects, returning the difference between
129** them.
130*/
131extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
132
133
134SEC_END_PROTOS
135
136#endif /* _SECDIG_H_ */