Blame nss/lib/util/secdig.h

Packit 40b132
/*
Packit 40b132
 * secdig.h - public prototypes for digest-info functions
Packit 40b132
 *
Packit 40b132
 * This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit 40b132
Packit 40b132
#ifndef _SECDIG_H_
Packit 40b132
#define _SECDIG_H_
Packit 40b132
Packit 40b132
#include "utilrename.h"
Packit 40b132
#include "secdigt.h"
Packit 40b132
Packit 40b132
#include "seccomon.h"
Packit 40b132
#include "secasn1t.h" 
Packit 40b132
#include "secdert.h"
Packit 40b132
Packit 40b132
SEC_BEGIN_PROTOS
Packit 40b132
Packit 40b132
Packit 40b132
extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
Packit 40b132
Packit 40b132
SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
Packit 40b132
Packit 40b132
/****************************************/
Packit 40b132
/*
Packit 40b132
** Digest-info functions
Packit 40b132
*/
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Create a new digest-info object
Packit 40b132
** 	"algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
Packit 40b132
** 	"sig" the raw signature data (from MD2 or MD5)
Packit 40b132
** 	"sigLen" the length of the signature data
Packit 40b132
**
Packit 40b132
** NOTE: this is a low level routine used to prepare some data for PKCS#1
Packit 40b132
** digital signature formatting.
Packit 40b132
**
Packit 40b132
** XXX It might be nice to combine the create and encode functions.
Packit 40b132
** I think that is all anybody ever wants to do anyway.
Packit 40b132
*/
Packit 40b132
extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
Packit 40b132
					   const unsigned char *sig,
Packit 40b132
					   unsigned int sigLen);
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Destroy a digest-info object
Packit 40b132
*/
Packit 40b132
extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Encode a digest-info object
Packit 40b132
**	"poolp" is where to allocate the result from; it can be NULL in
Packit 40b132
**		which case generic heap allocation (XP_ALLOC) will be used
Packit 40b132
**	"dest" is where to store the result; it can be NULL, in which case
Packit 40b132
**		it will be allocated (from poolp or heap, as explained above)
Packit 40b132
**	"diginfo" is the object to be encoded
Packit 40b132
** The return value is NULL if any error occurred, otherwise it is the
Packit 40b132
** resulting SECItem (either allocated or the same as the "dest" parameter).
Packit 40b132
**
Packit 40b132
** XXX It might be nice to combine the create and encode functions.
Packit 40b132
** I think that is all anybody ever wants to do anyway.
Packit 40b132
*/
Packit 40b132
extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest,
Packit 40b132
				     SGNDigestInfo *diginfo);
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Decode a DER encoded digest info objct.
Packit 40b132
**  didata is thr source of the encoded digest.  
Packit 40b132
** The return value is NULL if an error occurs.  Otherwise, a
Packit 40b132
** digest info object which is allocated within it's own
Packit 40b132
** pool is returned.  The digest info should be deleted
Packit 40b132
** by later calling SGN_DestroyDigestInfo.
Packit 40b132
*/
Packit 40b132
extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
Packit 40b132
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Copy digest info.
Packit 40b132
**  poolp is the arena to which the digest will be copied.
Packit 40b132
**  a is the destination digest, it must be non-NULL.
Packit 40b132
**  b is the source digest
Packit 40b132
** This function is for copying digests.  It allows digests
Packit 40b132
** to be copied into a specified pool.  If the digest is in
Packit 40b132
** the same pool as other data, you do not want to delete
Packit 40b132
** the digest by calling SGN_DestroyDigestInfo.  
Packit 40b132
** A return value of SECFailure indicates an error.  A return
Packit 40b132
** of SECSuccess indicates no error occurred.
Packit 40b132
*/
Packit 40b132
extern SECStatus  SGN_CopyDigestInfo(PLArenaPool *poolp,
Packit 40b132
					SGNDigestInfo *a, 
Packit 40b132
					SGNDigestInfo *b);
Packit 40b132
Packit 40b132
/*
Packit 40b132
** Compare two digest-info objects, returning the difference between
Packit 40b132
** them.
Packit 40b132
*/
Packit 40b132
extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
Packit 40b132
Packit 40b132
Packit 40b132
SEC_END_PROTOS
Packit 40b132
Packit 40b132
#endif /* _SECDIG_H_ */