PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/secoid.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 152 lines | 31 code | 23 blank | 98 comment | 0 complexity | dec9b86eff3dc0cc7330af21f162e3b8 MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  4 * The contents of this file are subject to the Mozilla Public License Version
  5 * 1.1 (the "License"); you may not use this file except in compliance with
  6 * the License. You may obtain a copy of the License at
  7 * http://www.mozilla.org/MPL/
  8 *
  9 * Software distributed under the License is distributed on an "AS IS" basis,
 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 11 * for the specific language governing rights and limitations under the
 12 * License.
 13 *
 14 * The Original Code is the Netscape security libraries.
 15 *
 16 * The Initial Developer of the Original Code is
 17 * Netscape Communications Corporation.
 18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
 19 * the Initial Developer. All Rights Reserved.
 20 *
 21 * Contributor(s):
 22 *
 23 * Alternatively, the contents of this file may be used under the terms of
 24 * either the GNU General Public License Version 2 or later (the "GPL"), or
 25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 26 * in which case the provisions of the GPL or the LGPL are applicable instead
 27 * of those above. If you wish to allow use of your version of this file only
 28 * under the terms of either the GPL or the LGPL, and not to allow others to
 29 * use your version of this file under the terms of the MPL, indicate your
 30 * decision by deleting the provisions above and replace them with the notice
 31 * and other provisions required by the GPL or the LGPL. If you do not delete
 32 * the provisions above, a recipient may use your version of this file under
 33 * the terms of any one of the MPL, the GPL or the LGPL.
 34 *
 35 * ***** END LICENSE BLOCK ***** */
 36
 37#ifndef _SECOID_H_
 38#define _SECOID_H_
 39
 40#include "utilrename.h"
 41
 42/*
 43 * secoid.h - public data structures and prototypes for ASN.1 OID functions
 44 *
 45 * $Id: secoid.h,v 1.9 2008/02/16 04:38:09 julien.pierre.boogz%sun.com Exp $
 46 */
 47
 48#include "plarena.h"
 49
 50#include "seccomon.h"
 51#include "secoidt.h"
 52#include "secasn1t.h"
 53
 54SEC_BEGIN_PROTOS
 55
 56extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[];
 57
 58/* This functions simply returns the address of the above-declared template. */
 59SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate)
 60
 61/*
 62 * OID handling routines
 63 */
 64extern SECOidData *SECOID_FindOID( const SECItem *oid);
 65extern SECOidTag SECOID_FindOIDTag(const SECItem *oid);
 66extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum);
 67extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism);
 68
 69/****************************************/
 70/*
 71** Algorithm id handling operations
 72*/
 73
 74/*
 75** Fill in an algorithm-ID object given a tag and some parameters.
 76** 	"aid" where the DER encoded algorithm info is stored (memory
 77**	   is allocated)
 78**	"tag" the tag number defining the algorithm 
 79**	"params" if not NULL, the parameters to go with the algorithm
 80*/
 81extern SECStatus SECOID_SetAlgorithmID(PRArenaPool *arena, SECAlgorithmID *aid,
 82				   SECOidTag tag, SECItem *params);
 83
 84/*
 85** Copy the "src" object to "dest". Memory is allocated in "dest" for
 86** each of the appropriate sub-objects. Memory in "dest" is not freed
 87** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE)
 88** to do that).
 89*/
 90extern SECStatus SECOID_CopyAlgorithmID(PRArenaPool *arena, SECAlgorithmID *dest,
 91				    SECAlgorithmID *src);
 92
 93/*
 94** Get the tag number for the given algorithm-id object.
 95*/
 96extern SECOidTag SECOID_GetAlgorithmTag(SECAlgorithmID *aid);
 97
 98/*
 99** Destroy an algorithm-id object.
100**	"aid" the certificate-request to destroy
101**	"freeit" if PR_TRUE then free the object as well as its sub-objects
102*/
103extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit);
104
105/*
106** Compare two algorithm-id objects, returning the difference between
107** them.
108*/
109extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a,
110					   SECAlgorithmID *b);
111
112extern PRBool SECOID_KnownCertExtenOID (SECItem *extenOid);
113
114/* Given a tag number, return a string describing it.
115 */
116extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum);
117
118/* Add a dynamic SECOidData to the dynamic OID table.
119** Routine copies the src entry, and returns the new SECOidTag.
120** Returns SEC_OID_INVALID if failed to add for some reason.
121*/
122extern SECOidTag SECOID_AddEntry(const SECOidData * src);
123
124/*
125 * initialize the oid data structures.
126 */
127extern SECStatus SECOID_Init(void);
128
129/*
130 * free up the oid data structures.
131 */
132extern SECStatus SECOID_Shutdown(void);
133
134/* if to->data is not NULL, and to->len is large enough to hold the result,
135 * then the resultant OID will be copyed into to->data, and to->len will be
136 * changed to show the actual OID length.
137 * Otherwise, memory for the OID will be allocated (from the caller's 
138 * PLArenaPool, if pool is non-NULL) and to->data will receive the address
139 * of the allocated data, and to->len will receive the OID length.
140 * The original value of to->data is not freed when a new buffer is allocated.
141 * 
142 * The input string may begin with "OID." and this still be ignored.
143 * The length of the input string is given in len.  If len == 0, then 
144 * len will be computed as strlen(from), meaning it must be NUL terminated.
145 * It is an error if from == NULL, or if *from == '\0'.
146 */
147extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to, 
148                                 const char *from, PRUint32 len);
149
150SEC_END_PROTOS
151
152#endif /* _SECOID_H_ */