security/nss/lib/util/secoid.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/util/secoid.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _SECOID_H_
     1.9 +#define _SECOID_H_
    1.10 +
    1.11 +#include "utilrename.h"
    1.12 +
    1.13 +/*
    1.14 + * secoid.h - public data structures and prototypes for ASN.1 OID functions
    1.15 + */
    1.16 +
    1.17 +#include "plarena.h"
    1.18 +
    1.19 +#include "seccomon.h"
    1.20 +#include "secoidt.h"
    1.21 +#include "secasn1t.h"
    1.22 +
    1.23 +SEC_BEGIN_PROTOS
    1.24 +
    1.25 +extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[];
    1.26 +
    1.27 +/* This functions simply returns the address of the above-declared template. */
    1.28 +SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate)
    1.29 +
    1.30 +/*
    1.31 + * OID handling routines
    1.32 + */
    1.33 +extern SECOidData *SECOID_FindOID( const SECItem *oid);
    1.34 +extern SECOidTag SECOID_FindOIDTag(const SECItem *oid);
    1.35 +extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum);
    1.36 +extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism);
    1.37 +
    1.38 +/****************************************/
    1.39 +/*
    1.40 +** Algorithm id handling operations
    1.41 +*/
    1.42 +
    1.43 +/*
    1.44 +** Fill in an algorithm-ID object given a tag and some parameters.
    1.45 +** 	"aid" where the DER encoded algorithm info is stored (memory
    1.46 +**	   is allocated)
    1.47 +**	"tag" the tag number defining the algorithm 
    1.48 +**	"params" if not NULL, the parameters to go with the algorithm
    1.49 +*/
    1.50 +extern SECStatus SECOID_SetAlgorithmID(PLArenaPool *arena, SECAlgorithmID *aid,
    1.51 +				   SECOidTag tag, SECItem *params);
    1.52 +
    1.53 +/*
    1.54 +** Copy the "src" object to "dest". Memory is allocated in "dest" for
    1.55 +** each of the appropriate sub-objects. Memory in "dest" is not freed
    1.56 +** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE)
    1.57 +** to do that).
    1.58 +*/
    1.59 +extern SECStatus SECOID_CopyAlgorithmID(PLArenaPool *arena, SECAlgorithmID *dest,
    1.60 +				        const SECAlgorithmID *src);
    1.61 +
    1.62 +/*
    1.63 +** Get the tag number for the given algorithm-id object.
    1.64 +*/
    1.65 +extern SECOidTag SECOID_GetAlgorithmTag(const SECAlgorithmID *aid);
    1.66 +
    1.67 +/*
    1.68 +** Destroy an algorithm-id object.
    1.69 +**	"aid" the certificate-request to destroy
    1.70 +**	"freeit" if PR_TRUE then free the object as well as its sub-objects
    1.71 +*/
    1.72 +extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit);
    1.73 +
    1.74 +/*
    1.75 +** Compare two algorithm-id objects, returning the difference between
    1.76 +** them.
    1.77 +*/
    1.78 +extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a,
    1.79 +					   SECAlgorithmID *b);
    1.80 +
    1.81 +extern PRBool SECOID_KnownCertExtenOID (SECItem *extenOid);
    1.82 +
    1.83 +/* Given a tag number, return a string describing it.
    1.84 + */
    1.85 +extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum);
    1.86 +
    1.87 +/* Add a dynamic SECOidData to the dynamic OID table.
    1.88 +** Routine copies the src entry, and returns the new SECOidTag.
    1.89 +** Returns SEC_OID_INVALID if failed to add for some reason.
    1.90 +*/
    1.91 +extern SECOidTag SECOID_AddEntry(const SECOidData * src);
    1.92 +
    1.93 +/*
    1.94 + * initialize the oid data structures.
    1.95 + */
    1.96 +extern SECStatus SECOID_Init(void);
    1.97 +
    1.98 +/*
    1.99 + * free up the oid data structures.
   1.100 + */
   1.101 +extern SECStatus SECOID_Shutdown(void);
   1.102 +
   1.103 +/* if to->data is not NULL, and to->len is large enough to hold the result,
   1.104 + * then the resultant OID will be copyed into to->data, and to->len will be
   1.105 + * changed to show the actual OID length.
   1.106 + * Otherwise, memory for the OID will be allocated (from the caller's 
   1.107 + * PLArenaPool, if pool is non-NULL) and to->data will receive the address
   1.108 + * of the allocated data, and to->len will receive the OID length.
   1.109 + * The original value of to->data is not freed when a new buffer is allocated.
   1.110 + * 
   1.111 + * The input string may begin with "OID." and this still be ignored.
   1.112 + * The length of the input string is given in len.  If len == 0, then 
   1.113 + * len will be computed as strlen(from), meaning it must be NUL terminated.
   1.114 + * It is an error if from == NULL, or if *from == '\0'.
   1.115 + */
   1.116 +extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to, 
   1.117 +                                 const char *from, PRUint32 len);
   1.118 +
   1.119 +extern void UTIL_SetForkState(PRBool forked);
   1.120 +
   1.121 +/*
   1.122 + * Accessor functions for new opaque extended SECOID table.
   1.123 + * Any of these functions may return SECSuccess or SECFailure with the error 
   1.124 + * code set to SEC_ERROR_UNKNOWN_OBJECT_TYPE if the SECOidTag is out of range.
   1.125 + */
   1.126 +
   1.127 +/* The Get function outputs the 32-bit value associated with the SECOidTag.
   1.128 + * Flags bits are the NSS_USE_ALG_ #defines in "secoidt.h".
   1.129 + * Default value for any algorithm is 0xffffffff (enabled for all purposes).
   1.130 + * No value is output if function returns SECFailure.
   1.131 + */
   1.132 +extern SECStatus NSS_GetAlgorithmPolicy(SECOidTag tag, PRUint32 *pValue);
   1.133 +
   1.134 +/* The Set function modifies the stored value according to the following
   1.135 + * algorithm:
   1.136 + *   policy[tag] = (policy[tag] & ~clearBits) | setBits;
   1.137 + */
   1.138 +extern SECStatus
   1.139 +NSS_SetAlgorithmPolicy(SECOidTag tag, PRUint32 setBits, PRUint32 clearBits);
   1.140 +
   1.141 +
   1.142 +SEC_END_PROTOS
   1.143 +
   1.144 +#endif /* _SECOID_H_ */

mercurial