1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/util/secdig.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* 1.5 + * secdig.h - public prototypes for digest-info functions 1.6 + * 1.7 + * This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef _SECDIG_H_ 1.12 +#define _SECDIG_H_ 1.13 + 1.14 +#include "utilrename.h" 1.15 +#include "secdigt.h" 1.16 + 1.17 +#include "seccomon.h" 1.18 +#include "secasn1t.h" 1.19 +#include "secdert.h" 1.20 + 1.21 +SEC_BEGIN_PROTOS 1.22 + 1.23 + 1.24 +extern const SEC_ASN1Template sgn_DigestInfoTemplate[]; 1.25 + 1.26 +SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate) 1.27 + 1.28 +/****************************************/ 1.29 +/* 1.30 +** Digest-info functions 1.31 +*/ 1.32 + 1.33 +/* 1.34 +** Create a new digest-info object 1.35 +** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1 1.36 +** "sig" the raw signature data (from MD2 or MD5) 1.37 +** "sigLen" the length of the signature data 1.38 +** 1.39 +** NOTE: this is a low level routine used to prepare some data for PKCS#1 1.40 +** digital signature formatting. 1.41 +** 1.42 +** XXX It might be nice to combine the create and encode functions. 1.43 +** I think that is all anybody ever wants to do anyway. 1.44 +*/ 1.45 +extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm, 1.46 + const unsigned char *sig, 1.47 + unsigned int sigLen); 1.48 + 1.49 +/* 1.50 +** Destroy a digest-info object 1.51 +*/ 1.52 +extern void SGN_DestroyDigestInfo(SGNDigestInfo *info); 1.53 + 1.54 +/* 1.55 +** Encode a digest-info object 1.56 +** "poolp" is where to allocate the result from; it can be NULL in 1.57 +** which case generic heap allocation (XP_ALLOC) will be used 1.58 +** "dest" is where to store the result; it can be NULL, in which case 1.59 +** it will be allocated (from poolp or heap, as explained above) 1.60 +** "diginfo" is the object to be encoded 1.61 +** The return value is NULL if any error occurred, otherwise it is the 1.62 +** resulting SECItem (either allocated or the same as the "dest" parameter). 1.63 +** 1.64 +** XXX It might be nice to combine the create and encode functions. 1.65 +** I think that is all anybody ever wants to do anyway. 1.66 +*/ 1.67 +extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest, 1.68 + SGNDigestInfo *diginfo); 1.69 + 1.70 +/* 1.71 +** Decode a DER encoded digest info objct. 1.72 +** didata is thr source of the encoded digest. 1.73 +** The return value is NULL if an error occurs. Otherwise, a 1.74 +** digest info object which is allocated within it's own 1.75 +** pool is returned. The digest info should be deleted 1.76 +** by later calling SGN_DestroyDigestInfo. 1.77 +*/ 1.78 +extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata); 1.79 + 1.80 + 1.81 +/* 1.82 +** Copy digest info. 1.83 +** poolp is the arena to which the digest will be copied. 1.84 +** a is the destination digest, it must be non-NULL. 1.85 +** b is the source digest 1.86 +** This function is for copying digests. It allows digests 1.87 +** to be copied into a specified pool. If the digest is in 1.88 +** the same pool as other data, you do not want to delete 1.89 +** the digest by calling SGN_DestroyDigestInfo. 1.90 +** A return value of SECFailure indicates an error. A return 1.91 +** of SECSuccess indicates no error occurred. 1.92 +*/ 1.93 +extern SECStatus SGN_CopyDigestInfo(PLArenaPool *poolp, 1.94 + SGNDigestInfo *a, 1.95 + SGNDigestInfo *b); 1.96 + 1.97 +/* 1.98 +** Compare two digest-info objects, returning the difference between 1.99 +** them. 1.100 +*/ 1.101 +extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b); 1.102 + 1.103 + 1.104 +SEC_END_PROTOS 1.105 + 1.106 +#endif /* _SECDIG_H_ */