security/nss/lib/util/secdig.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * secdig.h - public prototypes for digest-info functions
michael@0 3 *
michael@0 4 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #ifndef _SECDIG_H_
michael@0 9 #define _SECDIG_H_
michael@0 10
michael@0 11 #include "utilrename.h"
michael@0 12 #include "secdigt.h"
michael@0 13
michael@0 14 #include "seccomon.h"
michael@0 15 #include "secasn1t.h"
michael@0 16 #include "secdert.h"
michael@0 17
michael@0 18 SEC_BEGIN_PROTOS
michael@0 19
michael@0 20
michael@0 21 extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
michael@0 22
michael@0 23 SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
michael@0 24
michael@0 25 /****************************************/
michael@0 26 /*
michael@0 27 ** Digest-info functions
michael@0 28 */
michael@0 29
michael@0 30 /*
michael@0 31 ** Create a new digest-info object
michael@0 32 ** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
michael@0 33 ** "sig" the raw signature data (from MD2 or MD5)
michael@0 34 ** "sigLen" the length of the signature data
michael@0 35 **
michael@0 36 ** NOTE: this is a low level routine used to prepare some data for PKCS#1
michael@0 37 ** digital signature formatting.
michael@0 38 **
michael@0 39 ** XXX It might be nice to combine the create and encode functions.
michael@0 40 ** I think that is all anybody ever wants to do anyway.
michael@0 41 */
michael@0 42 extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
michael@0 43 const unsigned char *sig,
michael@0 44 unsigned int sigLen);
michael@0 45
michael@0 46 /*
michael@0 47 ** Destroy a digest-info object
michael@0 48 */
michael@0 49 extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
michael@0 50
michael@0 51 /*
michael@0 52 ** Encode a digest-info object
michael@0 53 ** "poolp" is where to allocate the result from; it can be NULL in
michael@0 54 ** which case generic heap allocation (XP_ALLOC) will be used
michael@0 55 ** "dest" is where to store the result; it can be NULL, in which case
michael@0 56 ** it will be allocated (from poolp or heap, as explained above)
michael@0 57 ** "diginfo" is the object to be encoded
michael@0 58 ** The return value is NULL if any error occurred, otherwise it is the
michael@0 59 ** resulting SECItem (either allocated or the same as the "dest" parameter).
michael@0 60 **
michael@0 61 ** XXX It might be nice to combine the create and encode functions.
michael@0 62 ** I think that is all anybody ever wants to do anyway.
michael@0 63 */
michael@0 64 extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest,
michael@0 65 SGNDigestInfo *diginfo);
michael@0 66
michael@0 67 /*
michael@0 68 ** Decode a DER encoded digest info objct.
michael@0 69 ** didata is thr source of the encoded digest.
michael@0 70 ** The return value is NULL if an error occurs. Otherwise, a
michael@0 71 ** digest info object which is allocated within it's own
michael@0 72 ** pool is returned. The digest info should be deleted
michael@0 73 ** by later calling SGN_DestroyDigestInfo.
michael@0 74 */
michael@0 75 extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
michael@0 76
michael@0 77
michael@0 78 /*
michael@0 79 ** Copy digest info.
michael@0 80 ** poolp is the arena to which the digest will be copied.
michael@0 81 ** a is the destination digest, it must be non-NULL.
michael@0 82 ** b is the source digest
michael@0 83 ** This function is for copying digests. It allows digests
michael@0 84 ** to be copied into a specified pool. If the digest is in
michael@0 85 ** the same pool as other data, you do not want to delete
michael@0 86 ** the digest by calling SGN_DestroyDigestInfo.
michael@0 87 ** A return value of SECFailure indicates an error. A return
michael@0 88 ** of SECSuccess indicates no error occurred.
michael@0 89 */
michael@0 90 extern SECStatus SGN_CopyDigestInfo(PLArenaPool *poolp,
michael@0 91 SGNDigestInfo *a,
michael@0 92 SGNDigestInfo *b);
michael@0 93
michael@0 94 /*
michael@0 95 ** Compare two digest-info objects, returning the difference between
michael@0 96 ** them.
michael@0 97 */
michael@0 98 extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
michael@0 99
michael@0 100
michael@0 101 SEC_END_PROTOS
michael@0 102
michael@0 103 #endif /* _SECDIG_H_ */

mercurial