michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _SECOID_H_ michael@0: #define _SECOID_H_ michael@0: michael@0: #include "utilrename.h" michael@0: michael@0: /* michael@0: * secoid.h - public data structures and prototypes for ASN.1 OID functions michael@0: */ michael@0: michael@0: #include "plarena.h" michael@0: michael@0: #include "seccomon.h" michael@0: #include "secoidt.h" michael@0: #include "secasn1t.h" michael@0: michael@0: SEC_BEGIN_PROTOS michael@0: michael@0: extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[]; michael@0: michael@0: /* This functions simply returns the address of the above-declared template. */ michael@0: SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate) michael@0: michael@0: /* michael@0: * OID handling routines michael@0: */ michael@0: extern SECOidData *SECOID_FindOID( const SECItem *oid); michael@0: extern SECOidTag SECOID_FindOIDTag(const SECItem *oid); michael@0: extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum); michael@0: extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism); michael@0: michael@0: /****************************************/ michael@0: /* michael@0: ** Algorithm id handling operations michael@0: */ michael@0: michael@0: /* michael@0: ** Fill in an algorithm-ID object given a tag and some parameters. michael@0: ** "aid" where the DER encoded algorithm info is stored (memory michael@0: ** is allocated) michael@0: ** "tag" the tag number defining the algorithm michael@0: ** "params" if not NULL, the parameters to go with the algorithm michael@0: */ michael@0: extern SECStatus SECOID_SetAlgorithmID(PLArenaPool *arena, SECAlgorithmID *aid, michael@0: SECOidTag tag, SECItem *params); michael@0: michael@0: /* michael@0: ** Copy the "src" object to "dest". Memory is allocated in "dest" for michael@0: ** each of the appropriate sub-objects. Memory in "dest" is not freed michael@0: ** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE) michael@0: ** to do that). michael@0: */ michael@0: extern SECStatus SECOID_CopyAlgorithmID(PLArenaPool *arena, SECAlgorithmID *dest, michael@0: const SECAlgorithmID *src); michael@0: michael@0: /* michael@0: ** Get the tag number for the given algorithm-id object. michael@0: */ michael@0: extern SECOidTag SECOID_GetAlgorithmTag(const SECAlgorithmID *aid); michael@0: michael@0: /* michael@0: ** Destroy an algorithm-id object. michael@0: ** "aid" the certificate-request to destroy michael@0: ** "freeit" if PR_TRUE then free the object as well as its sub-objects michael@0: */ michael@0: extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit); michael@0: michael@0: /* michael@0: ** Compare two algorithm-id objects, returning the difference between michael@0: ** them. michael@0: */ michael@0: extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a, michael@0: SECAlgorithmID *b); michael@0: michael@0: extern PRBool SECOID_KnownCertExtenOID (SECItem *extenOid); michael@0: michael@0: /* Given a tag number, return a string describing it. michael@0: */ michael@0: extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum); michael@0: michael@0: /* Add a dynamic SECOidData to the dynamic OID table. michael@0: ** Routine copies the src entry, and returns the new SECOidTag. michael@0: ** Returns SEC_OID_INVALID if failed to add for some reason. michael@0: */ michael@0: extern SECOidTag SECOID_AddEntry(const SECOidData * src); michael@0: michael@0: /* michael@0: * initialize the oid data structures. michael@0: */ michael@0: extern SECStatus SECOID_Init(void); michael@0: michael@0: /* michael@0: * free up the oid data structures. michael@0: */ michael@0: extern SECStatus SECOID_Shutdown(void); michael@0: michael@0: /* if to->data is not NULL, and to->len is large enough to hold the result, michael@0: * then the resultant OID will be copyed into to->data, and to->len will be michael@0: * changed to show the actual OID length. michael@0: * Otherwise, memory for the OID will be allocated (from the caller's michael@0: * PLArenaPool, if pool is non-NULL) and to->data will receive the address michael@0: * of the allocated data, and to->len will receive the OID length. michael@0: * The original value of to->data is not freed when a new buffer is allocated. michael@0: * michael@0: * The input string may begin with "OID." and this still be ignored. michael@0: * The length of the input string is given in len. If len == 0, then michael@0: * len will be computed as strlen(from), meaning it must be NUL terminated. michael@0: * It is an error if from == NULL, or if *from == '\0'. michael@0: */ michael@0: extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to, michael@0: const char *from, PRUint32 len); michael@0: michael@0: extern void UTIL_SetForkState(PRBool forked); michael@0: michael@0: /* michael@0: * Accessor functions for new opaque extended SECOID table. michael@0: * Any of these functions may return SECSuccess or SECFailure with the error michael@0: * code set to SEC_ERROR_UNKNOWN_OBJECT_TYPE if the SECOidTag is out of range. michael@0: */ michael@0: michael@0: /* The Get function outputs the 32-bit value associated with the SECOidTag. michael@0: * Flags bits are the NSS_USE_ALG_ #defines in "secoidt.h". michael@0: * Default value for any algorithm is 0xffffffff (enabled for all purposes). michael@0: * No value is output if function returns SECFailure. michael@0: */ michael@0: extern SECStatus NSS_GetAlgorithmPolicy(SECOidTag tag, PRUint32 *pValue); michael@0: michael@0: /* The Set function modifies the stored value according to the following michael@0: * algorithm: michael@0: * policy[tag] = (policy[tag] & ~clearBits) | setBits; michael@0: */ michael@0: extern SECStatus michael@0: NSS_SetAlgorithmPolicy(SECOidTag tag, PRUint32 setBits, PRUint32 clearBits); michael@0: michael@0: michael@0: SEC_END_PROTOS michael@0: michael@0: #endif /* _SECOID_H_ */