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