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