tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

secdig.h (3369B)


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