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