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