| OLD | NEW |
| (Empty) |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 4 | |
| 5 #ifndef _SECOID_H_ | |
| 6 #define _SECOID_H_ | |
| 7 | |
| 8 #include "utilrename.h" | |
| 9 | |
| 10 /* | |
| 11 * secoid.h - public data structures and prototypes for ASN.1 OID functions | |
| 12 * | |
| 13 * $Id: secoid.h,v 1.17 2012/04/25 14:50:16 gerv%gerv.net Exp $ | |
| 14 */ | |
| 15 | |
| 16 #include "plarena.h" | |
| 17 | |
| 18 #include "seccomon.h" | |
| 19 #include "secoidt.h" | |
| 20 #include "secasn1t.h" | |
| 21 | |
| 22 SEC_BEGIN_PROTOS | |
| 23 | |
| 24 extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[]; | |
| 25 | |
| 26 /* This functions simply returns the address of the above-declared template. */ | |
| 27 SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate) | |
| 28 | |
| 29 /* | |
| 30 * OID handling routines | |
| 31 */ | |
| 32 extern SECOidData *SECOID_FindOID( const SECItem *oid); | |
| 33 extern SECOidTag SECOID_FindOIDTag(const SECItem *oid); | |
| 34 extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum); | |
| 35 extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism); | |
| 36 | |
| 37 /****************************************/ | |
| 38 /* | |
| 39 ** Algorithm id handling operations | |
| 40 */ | |
| 41 | |
| 42 /* | |
| 43 ** Fill in an algorithm-ID object given a tag and some parameters. | |
| 44 ** "aid" where the DER encoded algorithm info is stored (memory | |
| 45 ** is allocated) | |
| 46 ** "tag" the tag number defining the algorithm | |
| 47 ** "params" if not NULL, the parameters to go with the algorithm | |
| 48 */ | |
| 49 extern SECStatus SECOID_SetAlgorithmID(PLArenaPool *arena, SECAlgorithmID *aid, | |
| 50 SECOidTag tag, SECItem *params); | |
| 51 | |
| 52 /* | |
| 53 ** Copy the "src" object to "dest". Memory is allocated in "dest" for | |
| 54 ** each of the appropriate sub-objects. Memory in "dest" is not freed | |
| 55 ** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE) | |
| 56 ** to do that). | |
| 57 */ | |
| 58 extern SECStatus SECOID_CopyAlgorithmID(PLArenaPool *arena, SECAlgorithmID *dest
, | |
| 59 SECAlgorithmID *src); | |
| 60 | |
| 61 /* | |
| 62 ** Get the tag number for the given algorithm-id object. | |
| 63 */ | |
| 64 extern SECOidTag SECOID_GetAlgorithmTag(SECAlgorithmID *aid); | |
| 65 | |
| 66 /* | |
| 67 ** Destroy an algorithm-id object. | |
| 68 ** "aid" the certificate-request to destroy | |
| 69 ** "freeit" if PR_TRUE then free the object as well as its sub-objects | |
| 70 */ | |
| 71 extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit); | |
| 72 | |
| 73 /* | |
| 74 ** Compare two algorithm-id objects, returning the difference between | |
| 75 ** them. | |
| 76 */ | |
| 77 extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a, | |
| 78 SECAlgorithmID *b); | |
| 79 | |
| 80 extern PRBool SECOID_KnownCertExtenOID (SECItem *extenOid); | |
| 81 | |
| 82 /* Given a tag number, return a string describing it. | |
| 83 */ | |
| 84 extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum); | |
| 85 | |
| 86 /* Add a dynamic SECOidData to the dynamic OID table. | |
| 87 ** Routine copies the src entry, and returns the new SECOidTag. | |
| 88 ** Returns SEC_OID_INVALID if failed to add for some reason. | |
| 89 */ | |
| 90 extern SECOidTag SECOID_AddEntry(const SECOidData * src); | |
| 91 | |
| 92 /* | |
| 93 * initialize the oid data structures. | |
| 94 */ | |
| 95 extern SECStatus SECOID_Init(void); | |
| 96 | |
| 97 /* | |
| 98 * free up the oid data structures. | |
| 99 */ | |
| 100 extern SECStatus SECOID_Shutdown(void); | |
| 101 | |
| 102 /* if to->data is not NULL, and to->len is large enough to hold the result, | |
| 103 * then the resultant OID will be copyed into to->data, and to->len will be | |
| 104 * changed to show the actual OID length. | |
| 105 * Otherwise, memory for the OID will be allocated (from the caller's | |
| 106 * PLArenaPool, if pool is non-NULL) and to->data will receive the address | |
| 107 * of the allocated data, and to->len will receive the OID length. | |
| 108 * The original value of to->data is not freed when a new buffer is allocated. | |
| 109 * | |
| 110 * The input string may begin with "OID." and this still be ignored. | |
| 111 * The length of the input string is given in len. If len == 0, then | |
| 112 * len will be computed as strlen(from), meaning it must be NUL terminated. | |
| 113 * It is an error if from == NULL, or if *from == '\0'. | |
| 114 */ | |
| 115 extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to, | |
| 116 const char *from, PRUint32 len); | |
| 117 | |
| 118 extern void UTIL_SetForkState(PRBool forked); | |
| 119 | |
| 120 /* | |
| 121 * Accessor functions for new opaque extended SECOID table. | |
| 122 * Any of these functions may return SECSuccess or SECFailure with the error | |
| 123 * code set to SEC_ERROR_UNKNOWN_OBJECT_TYPE if the SECOidTag is out of range. | |
| 124 */ | |
| 125 | |
| 126 /* The Get function outputs the 32-bit value associated with the SECOidTag. | |
| 127 * Flags bits are the NSS_USE_ALG_ #defines in "secoidt.h". | |
| 128 * Default value for any algorithm is 0xffffffff (enabled for all purposes). | |
| 129 * No value is output if function returns SECFailure. | |
| 130 */ | |
| 131 extern SECStatus NSS_GetAlgorithmPolicy(SECOidTag tag, PRUint32 *pValue); | |
| 132 | |
| 133 /* The Set function modifies the stored value according to the following | |
| 134 * algorithm: | |
| 135 * policy[tag] = (policy[tag] & ~clearBits) | setBits; | |
| 136 */ | |
| 137 extern SECStatus | |
| 138 NSS_SetAlgorithmPolicy(SECOidTag tag, PRUint32 setBits, PRUint32 clearBits); | |
| 139 | |
| 140 | |
| 141 SEC_END_PROTOS | |
| 142 | |
| 143 #endif /* _SECOID_H_ */ | |
| OLD | NEW |