secoid.c
上传用户:lyxiangda
上传日期:2007-01-12
资源大小:3042k
文件大小:60k
源码类别:

CA认证

开发平台:

WINDOWS

  1. /*
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is the Netscape security libraries.
  13.  * 
  14.  * The Initial Developer of the Original Code is Netscape
  15.  * Communications Corporation.  Portions created by Netscape are 
  16.  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
  17.  * Rights Reserved.
  18.  * 
  19.  * Contributor(s):
  20.  * 
  21.  * Alternatively, the contents of this file may be used under the
  22.  * terms of the GNU General Public License Version 2 or later (the
  23.  * "GPL"), in which case the provisions of the GPL are applicable 
  24.  * instead of those above.  If you wish to allow use of your 
  25.  * version of this file only under the terms of the GPL and not to
  26.  * allow others to use your version of this file under the MPL,
  27.  * indicate your decision by deleting the provisions above and
  28.  * replace them with the notice and other provisions required by
  29.  * the GPL.  If you do not delete the provisions above, a recipient
  30.  * may use your version of this file under either the MPL or the
  31.  * GPL.
  32.  */
  33. #include "secoid.h"
  34. #include "mcom_db.h"
  35. #include "pkcs11t.h"
  36. #include "secmodt.h"
  37. #include "secitem.h"
  38. #include "secerr.h"
  39. /* MISSI Mosaic Object ID space */
  40. #define MISSI 0x60, 0x86, 0x48, 0x01, 0x65, 0x02, 0x01, 0x01
  41. #define MISSI_OLD_KEA_DSS MISSI, 0x0c
  42. #define MISSI_OLD_DSS MISSI, 0x02
  43. #define MISSI_KEA_DSS MISSI, 0x14
  44. #define MISSI_DSS MISSI, 0x13
  45. #define MISSI_KEA               MISSI, 0x0a
  46. #define MISSI_ALT_KEA           MISSI, 0x16
  47. /**
  48.  ** The Netscape OID space is allocated by Terry Hayes.  If you need
  49.  ** a piece of the space, contact him at thayes@netscape.com.
  50.  **/
  51. /* Netscape Communications Corporation Object ID space */
  52. /* { 2 16 840 1 113730 } */
  53. #define NETSCAPE_OID 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42
  54. /* netscape certificate extensions */
  55. #define NETSCAPE_CERT_EXT NETSCAPE_OID, 0x01
  56. /* netscape data types */
  57. #define NETSCAPE_DATA_TYPE NETSCAPE_OID, 0x02
  58. /* netscape directory oid - owned by Tim Howes(howes@netscape.com) */
  59. #define NETSCAPE_DIRECTORY NETSCAPE_OID, 0x03
  60. /* various policy type OIDs */
  61. #define NETSCAPE_POLICY NETSCAPE_OID, 0x04
  62. /* netscape cert server oid */
  63. #define NETSCAPE_CERT_SERVER NETSCAPE_OID, 0x05
  64. #define NETSCAPE_CERT_SERVER_CRMF NETSCAPE_CERT_SERVER, 0x01
  65. /* various algorithm OIDs */
  66. #define NETSCAPE_ALGS NETSCAPE_OID, 0x06
  67. /* Netscape Other Name Types */
  68. #define NETSCAPE_NAME_COMPONENTS NETSCAPE_OID, 0x07
  69. /* these are old and should go away soon */
  70. #define OLD_NETSCAPE 0x60, 0x86, 0x48, 0xd8, 0x6a
  71. #define NS_CERT_EXT OLD_NETSCAPE, 0x01
  72. #define NS_FILE_TYPE OLD_NETSCAPE, 0x02
  73. #define NS_IMAGE_TYPE OLD_NETSCAPE, 0x03
  74. /* RSA OID name space */
  75. #define RSADSI 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d
  76. #define PKCS RSADSI, 0x01
  77. #define DIGEST RSADSI, 0x02
  78. #define CIPHER RSADSI, 0x03
  79. #define PKCS1 PKCS, 0x01
  80. #define PKCS5 PKCS, 0x05
  81. #define PKCS7 PKCS, 0x07
  82. #define PKCS9 PKCS, 0x09
  83. #define PKCS12 PKCS, 0x0c
  84. /* Fortezza algorithm OID space: { 2 16 840 1 101 2 1 1 } */
  85. /* ### mwelch -- Is this just for algorithms, or all of Fortezza? */
  86. #define FORTEZZA_ALG 0x60, 0x86, 0x48, 0x01, 0x65, 0x02, 0x01, 0x01
  87. /* Other OID name spaces */
  88. #define ALGORITHM 0x2b, 0x0e, 0x03, 0x02
  89. #define X500 0x55
  90. #define X520_ATTRIBUTE_TYPE X500, 0x04
  91. #define X500_ALG X500, 0x08
  92. #define X500_ALG_ENCRYPTION X500_ALG, 0x01
  93. /** X.509 v3 Extension OID 
  94.  ** {joint-iso-ccitt (2) ds(5) 29}
  95.  **/
  96. #define ID_CE_OID X500, 0x1d
  97. #define RFC1274_ATTR_TYPE  0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x1
  98. /* #define RFC2247_ATTR_TYPE  0x09, 0x92, 0x26, 0xf5, 0x98, 0x1e, 0x64, 0x1 this is WRONG! */
  99. /* PKCS #12 name spaces */
  100. #define PKCS12_MODE_IDS PKCS12, 0x01
  101. #define PKCS12_ESPVK_IDS PKCS12, 0x02
  102. #define PKCS12_BAG_IDS PKCS12, 0x03
  103. #define PKCS12_CERT_BAG_IDS PKCS12, 0x04
  104. #define PKCS12_OIDS PKCS12, 0x05
  105. #define PKCS12_PBE_IDS PKCS12_OIDS, 0x01
  106. #define PKCS12_ENVELOPING_IDS PKCS12_OIDS, 0x02
  107. #define PKCS12_SIGNATURE_IDS PKCS12_OIDS, 0x03
  108. #define PKCS12_V2_PBE_IDS PKCS12, 0x01
  109. #define PKCS9_CERT_TYPES PKCS9, 0x16
  110. #define PKCS9_CRL_TYPES PKCS9, 0x17
  111. #define PKCS9_SMIME_IDS PKCS9, 0x10
  112. #define PKCS9_SMIME_ATTRS PKCS9_SMIME_IDS, 2
  113. #define PKCS9_SMIME_ALGS PKCS9_SMIME_IDS, 3
  114. #define PKCS12_VERSION1 PKCS12, 0x0a
  115. #define PKCS12_V1_BAG_IDS PKCS12_VERSION1, 1
  116. /* for DSA algorithm */
  117. /* { iso(1) member-body(2) us(840) x9-57(10040) x9algorithm(4) } */
  118. #define ANSI_X9_ALGORITHM  0x2a, 0x86, 0x48, 0xce, 0x38, 0x4
  119. /* for DH algorithm */
  120. /* { iso(1) member-body(2) us(840) x9-57(10046) number-type(2) } */
  121. /* need real OID person to look at this, copied the above line
  122.  * and added 6 to second to last value (and changed '4' to '2' */
  123. #define ANSI_X942_ALGORITHM  0x2a, 0x86, 0x48, 0xce, 0x3e, 0x2
  124. #define VERISIGN 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x45
  125. #define PKIX 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07
  126. #define PKIX_CERT_EXTENSIONS PKIX, 1
  127. #define PKIX_POLICY_QUALIFIERS PKIX, 2
  128. #define PKIX_KEY_USAGE PKIX, 3
  129. #define PKIX_ACCESS_DESCRIPTION PKIX, 0x30
  130. #define PKIX_OCSP PKIX_ACCESS_DESCRIPTION, 1
  131. #define PKIX_ID_PKIP     PKIX, 5
  132. #define PKIX_ID_REGCTRL  PKIX_ID_PKIP, 1 
  133. #define PKIX_ID_REGINFO  PKIX_ID_PKIP, 2
  134. static unsigned char md2[] = { DIGEST, 0x02 };
  135. static unsigned char md4[] = { DIGEST, 0x04 };
  136. static unsigned char md5[] = { DIGEST, 0x05 };
  137. static unsigned char sha1[] = { ALGORITHM, 0x1a };
  138. static unsigned char rc2cbc[] = { CIPHER, 0x02 };
  139. static unsigned char rc4[] = { CIPHER, 0x04 };
  140. static unsigned char desede3cbc[] = { CIPHER, 0x07 };
  141. static unsigned char rc5cbcpad[] = { CIPHER, 0x09 };
  142. static unsigned char desecb[] = { ALGORITHM, 0x06 };
  143. static unsigned char descbc[] = { ALGORITHM, 0x07 };
  144. static unsigned char desofb[] = { ALGORITHM, 0x08 };
  145. static unsigned char descfb[] = { ALGORITHM, 0x09 };
  146. static unsigned char desmac[] = { ALGORITHM, 0x0a };
  147. static unsigned char desede[] = { ALGORITHM, 0x11 };
  148. static unsigned char isoSHAWithRSASignature[] = { ALGORITHM, 0xf };
  149. static unsigned char pkcs1RSAEncryption[] = { PKCS1, 0x01 };
  150. static unsigned char pkcs1MD2WithRSAEncryption[] = { PKCS1, 0x02 };
  151. static unsigned char pkcs1MD4WithRSAEncryption[] = { PKCS1, 0x03 };
  152. static unsigned char pkcs1MD5WithRSAEncryption[] = { PKCS1, 0x04 };
  153. static unsigned char pkcs1SHA1WithRSAEncryption[] = { PKCS1, 0x05 };
  154. static unsigned char pkcs5PbeWithMD2AndDEScbc[] = { PKCS5, 0x01 };
  155. static unsigned char pkcs5PbeWithMD5AndDEScbc[] = { PKCS5, 0x03 };
  156. static unsigned char pkcs5PbeWithSha1AndDEScbc[] = { PKCS5, 0x0a };
  157. static unsigned char pkcs7[] = { PKCS7 };
  158. static unsigned char pkcs7Data[] = { PKCS7, 0x01 };
  159. static unsigned char pkcs7SignedData[] = { PKCS7, 0x02 };
  160. static unsigned char pkcs7EnvelopedData[] = { PKCS7, 0x03 };
  161. static unsigned char pkcs7SignedEnvelopedData[] = { PKCS7, 0x04 };
  162. static unsigned char pkcs7DigestedData[] = { PKCS7, 0x05 };
  163. static unsigned char pkcs7EncryptedData[] = { PKCS7, 0x06 };
  164. static unsigned char pkcs9EmailAddress[] = { PKCS9, 0x01 };
  165. static unsigned char pkcs9UnstructuredName[] = { PKCS9, 0x02 };
  166. static unsigned char pkcs9ContentType[] = { PKCS9, 0x03 };
  167. static unsigned char pkcs9MessageDigest[] = { PKCS9, 0x04 };
  168. static unsigned char pkcs9SigningTime[] = { PKCS9, 0x05 };
  169. static unsigned char pkcs9CounterSignature[] = { PKCS9, 0x06 };
  170. static unsigned char pkcs9ChallengePassword[] = { PKCS9, 0x07 };
  171. static unsigned char pkcs9UnstructuredAddress[] = { PKCS9, 0x08 };
  172. static unsigned char pkcs9ExtendedCertificateAttributes[] = { PKCS9, 0x09 };
  173. static unsigned char pkcs9SMIMECapabilities[] = { PKCS9, 15 };
  174. static unsigned char x520CommonName[] = { X520_ATTRIBUTE_TYPE, 3 };
  175. static unsigned char x520CountryName[] = { X520_ATTRIBUTE_TYPE, 6 };
  176. static unsigned char x520LocalityName[] = { X520_ATTRIBUTE_TYPE, 7 };
  177. static unsigned char x520StateOrProvinceName[] = { X520_ATTRIBUTE_TYPE, 8 };
  178. static unsigned char x520OrgName[] = { X520_ATTRIBUTE_TYPE, 10 };
  179. static unsigned char x520OrgUnitName[] = { X520_ATTRIBUTE_TYPE, 11 };
  180. static unsigned char x520DnQualifier[] = { X520_ATTRIBUTE_TYPE, 46 };
  181. static unsigned char nsTypeGIF[] = { NETSCAPE_DATA_TYPE, 0x01 };
  182. static unsigned char nsTypeJPEG[] = { NETSCAPE_DATA_TYPE, 0x02 };
  183. static unsigned char nsTypeURL[] = { NETSCAPE_DATA_TYPE, 0x03 };
  184. static unsigned char nsTypeHTML[] = { NETSCAPE_DATA_TYPE, 0x04 };
  185. static unsigned char nsTypeCertSeq[] = { NETSCAPE_DATA_TYPE, 0x05 };
  186. static unsigned char missiCertKEADSSOld[] = { MISSI_OLD_KEA_DSS };
  187. static unsigned char missiCertDSSOld[] = { MISSI_OLD_DSS };
  188. static unsigned char missiCertKEADSS[] = { MISSI_KEA_DSS };
  189. static unsigned char missiCertDSS[] = { MISSI_DSS };
  190. static unsigned char missiCertKEA[] = { MISSI_KEA };
  191. static unsigned char missiCertAltKEA[] = { MISSI_ALT_KEA };
  192. static unsigned char x500RSAEncryption[] = { X500_ALG_ENCRYPTION, 0x01 };
  193. /* added for alg 1485 */
  194. static unsigned char rfc1274Uid[] = { RFC1274_ATTR_TYPE, 1 };
  195. static unsigned char rfc1274Mail[] = { RFC1274_ATTR_TYPE, 3 };
  196. static unsigned char rfc2247DomainComponent[] = { RFC1274_ATTR_TYPE, 25 };
  197. /* Netscape private certificate extensions */
  198. static unsigned char nsCertExtNetscapeOK[] = { NS_CERT_EXT, 1 };
  199. static unsigned char nsCertExtIssuerLogo[] = { NS_CERT_EXT, 2 };
  200. static unsigned char nsCertExtSubjectLogo[] = { NS_CERT_EXT, 3 };
  201. static unsigned char nsExtCertType[] = { NETSCAPE_CERT_EXT, 0x01 };
  202. static unsigned char nsExtBaseURL[] = { NETSCAPE_CERT_EXT, 0x02 };
  203. static unsigned char nsExtRevocationURL[] = { NETSCAPE_CERT_EXT, 0x03 };
  204. static unsigned char nsExtCARevocationURL[] = { NETSCAPE_CERT_EXT, 0x04 };
  205. static unsigned char nsExtCACRLURL[] = { NETSCAPE_CERT_EXT, 0x05 };
  206. static unsigned char nsExtCACertURL[] = { NETSCAPE_CERT_EXT, 0x06 };
  207. static unsigned char nsExtCertRenewalURL[] = { NETSCAPE_CERT_EXT, 0x07 };
  208. static unsigned char nsExtCAPolicyURL[] = { NETSCAPE_CERT_EXT, 0x08 };
  209. static unsigned char nsExtHomepageURL[] = { NETSCAPE_CERT_EXT, 0x09 };
  210. static unsigned char nsExtEntityLogo[] = { NETSCAPE_CERT_EXT, 0x0a };
  211. static unsigned char nsExtUserPicture[] = { NETSCAPE_CERT_EXT, 0x0b };
  212. static unsigned char nsExtSSLServerName[] = { NETSCAPE_CERT_EXT, 0x0c };
  213. static unsigned char nsExtComment[] = { NETSCAPE_CERT_EXT, 0x0d };
  214. /* the following 2 extensions are defined for and used by Cartman(NSM) */
  215. static unsigned char nsExtLostPasswordURL[] = { NETSCAPE_CERT_EXT, 0x0e };
  216. static unsigned char nsExtCertRenewalTime[] = { NETSCAPE_CERT_EXT, 0x0f };
  217. #define NETSCAPE_CERT_EXT_AIA NETSCAPE_CERT_EXT, 0x10
  218. static unsigned char nsExtAIACertRenewal[] = { NETSCAPE_CERT_EXT_AIA, 0x01 };
  219. static unsigned char nsExtCertScopeOfUse[] = { NETSCAPE_CERT_EXT, 0x11 };
  220. static unsigned char nsKeyUsageGovtApproved[] = { NETSCAPE_POLICY, 0x01 };
  221. /* Standard x.509 v3 Certificate Extensions */
  222. static unsigned char x509SubjectDirectoryAttr[] = { ID_CE_OID, 9 };
  223. static unsigned char x509SubjectKeyID[] = { ID_CE_OID, 14 };
  224. static unsigned char x509KeyUsage[] = { ID_CE_OID, 15 };
  225. static unsigned char x509PrivateKeyUsagePeriod[] = { ID_CE_OID, 16 };
  226. static unsigned char x509SubjectAltName[] = { ID_CE_OID, 17 };
  227. static unsigned char x509IssuerAltName[] = { ID_CE_OID, 18 };
  228. static unsigned char x509BasicConstraints[] = { ID_CE_OID, 19 };
  229. static unsigned char x509NameConstraints[] = { ID_CE_OID, 30 };
  230. static unsigned char x509CRLDistPoints[] = { ID_CE_OID, 31 };
  231. static unsigned char x509CertificatePolicies[] = { ID_CE_OID, 32 };
  232. static unsigned char x509PolicyMappings[] = { ID_CE_OID, 33 };
  233. static unsigned char x509PolicyConstraints[] = { ID_CE_OID, 34 };
  234. static unsigned char x509AuthKeyID[] = { ID_CE_OID, 35};
  235. static unsigned char x509ExtKeyUsage[] = { ID_CE_OID, 37};
  236. static unsigned char x509AuthInfoAccess[] = { PKIX_CERT_EXTENSIONS, 1 };
  237. /* Standard x.509 v3 CRL Extensions */
  238. static unsigned char x509CrlNumber[] = { ID_CE_OID, 20};
  239. static unsigned char x509ReasonCode[] = { ID_CE_OID, 21};
  240. static unsigned char x509InvalidDate[] = { ID_CE_OID, 24};
  241. /* pkcs 12 additions */
  242. static unsigned char pkcs12[] = { PKCS12 };
  243. static unsigned char pkcs12ModeIDs[] = { PKCS12_MODE_IDS };
  244. static unsigned char pkcs12ESPVKIDs[] = { PKCS12_ESPVK_IDS };
  245. static unsigned char pkcs12BagIDs[] = { PKCS12_BAG_IDS };
  246. static unsigned char pkcs12CertBagIDs[] = { PKCS12_CERT_BAG_IDS };
  247. static unsigned char pkcs12OIDs[] = { PKCS12_OIDS };
  248. static unsigned char pkcs12PBEIDs[] = { PKCS12_PBE_IDS };
  249. static unsigned char pkcs12EnvelopingIDs[] = { PKCS12_ENVELOPING_IDS };
  250. static unsigned char pkcs12SignatureIDs[] = { PKCS12_SIGNATURE_IDS };
  251. static unsigned char pkcs12PKCS8KeyShrouding[] = { PKCS12_ESPVK_IDS, 0x01 };
  252. static unsigned char pkcs12KeyBagID[] = { PKCS12_BAG_IDS, 0x01 };
  253. static unsigned char pkcs12CertAndCRLBagID[] = { PKCS12_BAG_IDS, 0x02 };
  254. static unsigned char pkcs12SecretBagID[] = { PKCS12_BAG_IDS, 0x03 };
  255. static unsigned char pkcs12X509CertCRLBag[] = { PKCS12_CERT_BAG_IDS, 0x01 };
  256. static unsigned char pkcs12SDSICertBag[] = { PKCS12_CERT_BAG_IDS, 0x02 };
  257. static unsigned char pkcs12PBEWithSha1And128BitRC4[] = { PKCS12_PBE_IDS, 0x01 };
  258. static unsigned char pkcs12PBEWithSha1And40BitRC4[] = { PKCS12_PBE_IDS, 0x02 };
  259. static unsigned char pkcs12PBEWithSha1AndTripleDESCBC[] = { PKCS12_PBE_IDS, 0x03 };
  260. static unsigned char pkcs12PBEWithSha1And128BitRC2CBC[] = { PKCS12_PBE_IDS, 0x04 };
  261. static unsigned char pkcs12PBEWithSha1And40BitRC2CBC[] = { PKCS12_PBE_IDS, 0x05 };
  262. static unsigned char pkcs12RSAEncryptionWith128BitRC4[] =
  263. { PKCS12_ENVELOPING_IDS, 0x01 };
  264. static unsigned char pkcs12RSAEncryptionWith40BitRC4[] = 
  265. { PKCS12_ENVELOPING_IDS, 0x02 };
  266. static unsigned char pkcs12RSAEncryptionWithTripleDES[] = 
  267. { PKCS12_ENVELOPING_IDS, 0x03 }; 
  268. static unsigned char pkcs12RSASignatureWithSHA1Digest[] =
  269. { PKCS12_SIGNATURE_IDS, 0x01 };
  270. static unsigned char ansix9DSASignature[] = { ANSI_X9_ALGORITHM, 0x01 };
  271. static unsigned char ansix9DSASignaturewithSHA1Digest[] =
  272. { ANSI_X9_ALGORITHM, 0x03 };
  273. static unsigned char bogusDSASignaturewithSHA1Digest[] =
  274.         { ALGORITHM, 0x1b };
  275. /* verisign OIDs */
  276. static unsigned char verisignUserNotices[] = { VERISIGN, 1, 7, 1, 1 };
  277. /* pkix OIDs */
  278. static unsigned char pkixCPSPointerQualifier[] = { PKIX_POLICY_QUALIFIERS, 1 };
  279. static unsigned char pkixUserNoticeQualifier[] = { PKIX_POLICY_QUALIFIERS, 2 };
  280. static unsigned char pkixOCSP[] = { PKIX_OCSP };
  281. static unsigned char pkixOCSPBasicResponse[] = { PKIX_OCSP, 1 };
  282. static unsigned char pkixOCSPNonce[] = { PKIX_OCSP, 2 };
  283. static unsigned char pkixOCSPCRL[] = { PKIX_OCSP, 3 };
  284. static unsigned char pkixOCSPResponse[] = { PKIX_OCSP, 4 };
  285. static unsigned char pkixOCSPNoCheck[] = { PKIX_OCSP, 5 };
  286. static unsigned char pkixOCSPArchiveCutoff[] = { PKIX_OCSP, 6 };
  287. static unsigned char pkixOCSPServiceLocator[] = { PKIX_OCSP, 7 };
  288. static unsigned char pkixRegCtrlRegToken[]       = { PKIX_ID_REGCTRL, 1};
  289. static unsigned char pkixRegCtrlAuthenticator[]  = { PKIX_ID_REGCTRL, 2};
  290. static unsigned char pkixRegCtrlPKIPubInfo[]     = { PKIX_ID_REGCTRL, 3};
  291. static unsigned char pkixRegCtrlPKIArchOptions[] = { PKIX_ID_REGCTRL, 4};
  292. static unsigned char pkixRegCtrlOldCertID[]      = { PKIX_ID_REGCTRL, 5};
  293. static unsigned char pkixRegCtrlProtEncKey[]     = { PKIX_ID_REGCTRL, 6};
  294. static unsigned char pkixRegInfoUTF8Pairs[]      = { PKIX_ID_REGINFO, 1};
  295. static unsigned char pkixRegInfoCertReq[]        = { PKIX_ID_REGINFO, 2};
  296. static unsigned char pkixExtendedKeyUsageServerAuth[] = 
  297.         { PKIX_KEY_USAGE, 1 };
  298. static unsigned char pkixExtendedKeyUsageClientAuth[] = 
  299.         { PKIX_KEY_USAGE, 2 };
  300. static unsigned char pkixExtendedKeyUsageCodeSign[] = 
  301.         { PKIX_KEY_USAGE, 3 };
  302. static unsigned char pkixExtendedKeyUsageEMailProtect[] = 
  303.         { PKIX_KEY_USAGE, 4 };
  304. static unsigned char pkixExtendedKeyUsageTimeStamp[] = 
  305.         { PKIX_KEY_USAGE, 8 };
  306. static unsigned char pkixOCSPResponderExtendedKeyUsage[] = 
  307.         { PKIX_KEY_USAGE, 9 };
  308. /* OIDs for Netscape defined algorithms */
  309. static unsigned char netscapeSMimeKEA[] = { NETSCAPE_ALGS, 0x01 };
  310. /* pkcs 12 version 1.0 ids */
  311. static unsigned char pkcs12V2PBEWithSha1And128BitRC4[] = { PKCS12_V2_PBE_IDS, 0x01 };
  312. static unsigned char pkcs12V2PBEWithSha1And40BitRC4[] = { PKCS12_V2_PBE_IDS, 0x02 };
  313. static unsigned char pkcs12V2PBEWithSha1And3KeyTripleDEScbc[] = { PKCS12_V2_PBE_IDS, 0x03 };
  314. static unsigned char pkcs12V2PBEWithSha1And2KeyTripleDEScbc[] = { PKCS12_V2_PBE_IDS, 0x04 };
  315. static unsigned char pkcs12V2PBEWithSha1And128BitRC2cbc[] = { PKCS12_V2_PBE_IDS, 0x05 };
  316. static unsigned char pkcs12V2PBEWithSha1And40BitRC2cbc[] = { PKCS12_V2_PBE_IDS, 0x06 };
  317. static unsigned char pkcs12SafeContentsID[] = {PKCS12_BAG_IDS, 0x04 };
  318. static unsigned char pkcs12PKCS8ShroudedKeyBagID[] = { PKCS12_BAG_IDS, 0x05 };
  319. static unsigned char pkcs12V1KeyBag[] = { PKCS12_V1_BAG_IDS, 0x01 };
  320. static unsigned char pkcs12V1PKCS8ShroudedKeyBag[] = { PKCS12_V1_BAG_IDS, 0x02 };
  321. static unsigned char pkcs12V1CertBag[] = { PKCS12_V1_BAG_IDS, 0x03 };
  322. static unsigned char pkcs12V1CRLBag[] = { PKCS12_V1_BAG_IDS, 0x04 };
  323. static unsigned char pkcs12V1SecretBag[] = { PKCS12_V1_BAG_IDS, 0x05 };
  324. static unsigned char pkcs12V1SafeContentsBag[] = { PKCS12_V1_BAG_IDS, 0x06 };
  325. static unsigned char pkcs9X509Certificate[] = { PKCS9_CERT_TYPES, 1 };
  326. static unsigned char pkcs9SDSICertificate[] = { PKCS9_CERT_TYPES, 2 };
  327. static unsigned char pkcs9X509CRL[] = { PKCS9_CRL_TYPES, 1 };
  328. static unsigned char pkcs9FriendlyName[] = { PKCS9, 20 };
  329. static unsigned char pkcs9LocalKeyID[] = { PKCS9, 21 };
  330. static unsigned char pkcs12KeyUsageAttr[] = { 2, 5, 29, 15 };
  331. /* Fortezza algorithm OIDs */
  332. static unsigned char skipjackCBC[] = { FORTEZZA_ALG, 0x04 };
  333. static unsigned char dhPublicKey[] = { ANSI_X942_ALGORITHM, 0x1 };
  334. /* Netscape other name types */
  335. static unsigned char netscapeNickname[] = { NETSCAPE_NAME_COMPONENTS, 0x01};
  336. /* OIDs needed for cert server */
  337. static unsigned char netscapeRecoveryRequest[] = 
  338.                                         { NETSCAPE_CERT_SERVER_CRMF, 0x01 };
  339. /* RFC2630 (CMS) OIDs */
  340. static unsigned char cmsESDH[] = { PKCS9_SMIME_ALGS, 5 };
  341. static unsigned char cms3DESwrap[] = { PKCS9_SMIME_ALGS, 6 };
  342. static unsigned char cmsRC2wrap[] = { PKCS9_SMIME_ALGS, 7 };
  343. /* RFC2633 SMIME message attributes */
  344. static unsigned char smimeEncryptionKeyPreference[] = { PKCS9_SMIME_ATTRS, 11 };
  345. /*
  346.  * NOTE: the order of these entries must mach the SECOidTag enum in secoidt.h!
  347.  */
  348. static SECOidData oids[] = {
  349.     { { siDEROID, NULL, 0 },
  350.   SEC_OID_UNKNOWN,
  351.   "Unknown OID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  352.     { { siDEROID, md2, sizeof(md2) },
  353.   SEC_OID_MD2,
  354.   "MD2", CKM_MD2, INVALID_CERT_EXTENSION },
  355.     { { siDEROID, md4, sizeof(md4) },
  356.   SEC_OID_MD4,
  357.   "MD4", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  358.     { { siDEROID, md5, sizeof(md5) },
  359.   SEC_OID_MD5,
  360.   "MD5", CKM_MD5, INVALID_CERT_EXTENSION },
  361.     { { siDEROID, sha1, sizeof(sha1) },
  362.   SEC_OID_SHA1,
  363.   "SHA-1", CKM_SHA_1, INVALID_CERT_EXTENSION },
  364.     { { siDEROID, rc2cbc, sizeof(rc2cbc) },
  365.   SEC_OID_RC2_CBC,
  366.   "RC2-CBC", CKM_RC2_CBC, INVALID_CERT_EXTENSION },
  367.     { { siDEROID, rc4, sizeof(rc4) },
  368.   SEC_OID_RC4,
  369.   "RC4", CKM_RC4, INVALID_CERT_EXTENSION },
  370.     { { siDEROID, desede3cbc, sizeof(desede3cbc) },
  371.   SEC_OID_DES_EDE3_CBC,
  372.   "DES-EDE3-CBC", CKM_DES3_CBC, INVALID_CERT_EXTENSION },
  373.     { { siDEROID, rc5cbcpad, sizeof(rc5cbcpad) },
  374.   SEC_OID_RC5_CBC_PAD,
  375.   "RC5-CBCPad", CKM_RC5_CBC, INVALID_CERT_EXTENSION },
  376.     { { siDEROID, desecb, sizeof(desecb) },
  377.   SEC_OID_DES_ECB,
  378.   "DES-ECB", CKM_DES_ECB, INVALID_CERT_EXTENSION },
  379.     { { siDEROID, descbc, sizeof(descbc) },
  380.   SEC_OID_DES_CBC,
  381.   "DES-CBC", CKM_DES_CBC, INVALID_CERT_EXTENSION },
  382.     { { siDEROID, desofb, sizeof(desofb) },
  383.   SEC_OID_DES_OFB,
  384.   "DES-OFB", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  385.     { { siDEROID, descfb, sizeof(descfb) },
  386.   SEC_OID_DES_CFB,
  387.   "DES-CFB", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  388.     { { siDEROID, desmac, sizeof(desmac) },
  389.   SEC_OID_DES_MAC,
  390.   "DES-MAC", CKM_DES_MAC, INVALID_CERT_EXTENSION },
  391.     { { siDEROID, desede, sizeof(desede) },
  392.   SEC_OID_DES_EDE,
  393.   "DES-EDE", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  394.     { { siDEROID, isoSHAWithRSASignature, sizeof(isoSHAWithRSASignature) },
  395.   SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE,
  396.   "ISO SHA with RSA Signature", CKM_INVALID_MECHANISM,
  397.   INVALID_CERT_EXTENSION },
  398.     { { siDEROID, pkcs1RSAEncryption, sizeof(pkcs1RSAEncryption) },
  399.   SEC_OID_PKCS1_RSA_ENCRYPTION,
  400.   "PKCS #1 RSA Encryption", CKM_RSA_PKCS, INVALID_CERT_EXTENSION },
  401.     /* the following Signing mechanisms should get new CKM_ values when
  402.      * values for CKM_RSA_WITH_MDX and CKM_RSA_WITH_SHA_1 get defined in
  403.      * PKCS #11.
  404.      */
  405.     { { siDEROID, pkcs1MD2WithRSAEncryption, sizeof(pkcs1MD2WithRSAEncryption) },
  406.   SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION,
  407.   "PKCS #1 MD2 With RSA Encryption", CKM_MD2_RSA_PKCS,
  408.   INVALID_CERT_EXTENSION },
  409.     { { siDEROID, pkcs1MD4WithRSAEncryption, sizeof(pkcs1MD4WithRSAEncryption) },
  410.   SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION,
  411.   "PKCS #1 MD4 With RSA Encryption", CKM_INVALID_MECHANISM,
  412.   INVALID_CERT_EXTENSION },
  413.     { { siDEROID, pkcs1MD5WithRSAEncryption, sizeof(pkcs1MD5WithRSAEncryption) },
  414.   SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION,
  415.   "PKCS #1 MD5 With RSA Encryption", CKM_MD5_RSA_PKCS,
  416.   INVALID_CERT_EXTENSION },
  417.     { { siDEROID, pkcs1SHA1WithRSAEncryption, sizeof(pkcs1SHA1WithRSAEncryption) },
  418.   SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION,
  419.   "PKCS #1 SHA-1 With RSA Encryption", CKM_SHA1_RSA_PKCS,
  420.   INVALID_CERT_EXTENSION },
  421.     { { siDEROID, pkcs5PbeWithMD2AndDEScbc, sizeof(pkcs5PbeWithMD2AndDEScbc) },
  422.   SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC,
  423.   "PKCS #5 Password Based Encryption with MD2 and DES CBC",
  424.   CKM_PBE_MD2_DES_CBC, INVALID_CERT_EXTENSION },
  425.     { { siDEROID, pkcs5PbeWithMD5AndDEScbc, sizeof(pkcs5PbeWithMD5AndDEScbc) },
  426.   SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC,
  427.   "PKCS #5 Password Based Encryption with MD5 and DES CBC",
  428.   CKM_PBE_MD5_DES_CBC, INVALID_CERT_EXTENSION },
  429.     { { siDEROID, pkcs5PbeWithSha1AndDEScbc,
  430.   sizeof(pkcs5PbeWithSha1AndDEScbc) },
  431.           SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC,
  432.   "PKCS #5 Password Based Encryption with SHA1 and DES CBC", 
  433.   CKM_NETSCAPE_PBE_SHA1_DES_CBC, INVALID_CERT_EXTENSION },
  434.     { { siDEROID, pkcs7, sizeof(pkcs7) },
  435.   SEC_OID_PKCS7,
  436.   "PKCS #7", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  437.     { { siDEROID, pkcs7Data, sizeof(pkcs7Data) },
  438.   SEC_OID_PKCS7_DATA,
  439.   "PKCS #7 Data", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  440.     { { siDEROID, pkcs7SignedData, sizeof(pkcs7SignedData) },
  441.   SEC_OID_PKCS7_SIGNED_DATA,
  442.   "PKCS #7 Signed Data", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  443.     { { siDEROID, pkcs7EnvelopedData, sizeof(pkcs7EnvelopedData) },
  444.   SEC_OID_PKCS7_ENVELOPED_DATA,
  445.   "PKCS #7 Enveloped Data", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  446.     { { siDEROID, pkcs7SignedEnvelopedData, sizeof(pkcs7SignedEnvelopedData) },
  447.   SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA,
  448.   "PKCS #7 Signed And Enveloped Data", CKM_INVALID_MECHANISM,
  449.   INVALID_CERT_EXTENSION },
  450.     { { siDEROID, pkcs7DigestedData, sizeof(pkcs7DigestedData) },
  451.   SEC_OID_PKCS7_DIGESTED_DATA,
  452.   "PKCS #7 Digested Data", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  453.     { { siDEROID, pkcs7EncryptedData, sizeof(pkcs7EncryptedData) },
  454.   SEC_OID_PKCS7_ENCRYPTED_DATA,
  455.   "PKCS #7 Encrypted Data", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  456.     { { siDEROID, pkcs9EmailAddress, sizeof(pkcs9EmailAddress) },
  457.   SEC_OID_PKCS9_EMAIL_ADDRESS,
  458.   "PKCS #9 Email Address", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  459.     { { siDEROID, pkcs9UnstructuredName, sizeof(pkcs9UnstructuredName) },
  460.   SEC_OID_PKCS9_UNSTRUCTURED_NAME,
  461.   "PKCS #9 Unstructured Name", CKM_INVALID_MECHANISM,
  462.   INVALID_CERT_EXTENSION },
  463.     { { siDEROID, pkcs9ContentType, sizeof(pkcs9ContentType) },
  464.   SEC_OID_PKCS9_CONTENT_TYPE,
  465.   "PKCS #9 Content Type", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  466.     { { siDEROID, pkcs9MessageDigest, sizeof(pkcs9MessageDigest) },
  467.   SEC_OID_PKCS9_MESSAGE_DIGEST,
  468.   "PKCS #9 Message Digest", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  469.     { { siDEROID, pkcs9SigningTime, sizeof(pkcs9SigningTime) },
  470.   SEC_OID_PKCS9_SIGNING_TIME,
  471.   "PKCS #9 Signing Time", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  472.     { { siDEROID, pkcs9CounterSignature, sizeof(pkcs9CounterSignature) },
  473.   SEC_OID_PKCS9_COUNTER_SIGNATURE,
  474.   "PKCS #9 Counter Signature", CKM_INVALID_MECHANISM,
  475.   INVALID_CERT_EXTENSION },
  476.     { { siDEROID, pkcs9ChallengePassword, sizeof(pkcs9ChallengePassword) },
  477.   SEC_OID_PKCS9_CHALLENGE_PASSWORD,
  478.   "PKCS #9 Challenge Password", CKM_INVALID_MECHANISM,
  479.   INVALID_CERT_EXTENSION },
  480.     { { siDEROID, pkcs9UnstructuredAddress, sizeof(pkcs9UnstructuredAddress) },
  481.   SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS,
  482.   "PKCS #9 Unstructured Address", CKM_INVALID_MECHANISM,
  483.   INVALID_CERT_EXTENSION },
  484.     { { siDEROID, pkcs9ExtendedCertificateAttributes,
  485.           sizeof(pkcs9ExtendedCertificateAttributes) },
  486.   SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES,
  487.   "PKCS #9 Extended Certificate Attributes", CKM_INVALID_MECHANISM,
  488.   INVALID_CERT_EXTENSION },
  489.     { { siDEROID, pkcs9SMIMECapabilities,
  490.           sizeof(pkcs9SMIMECapabilities) },
  491.   SEC_OID_PKCS9_SMIME_CAPABILITIES,
  492.   "PKCS #9 S/MIME Capabilities", CKM_INVALID_MECHANISM,
  493.   INVALID_CERT_EXTENSION },
  494.     { { siDEROID, x520CommonName,
  495.   sizeof(x520CommonName) },
  496.   SEC_OID_AVA_COMMON_NAME,
  497.   "X520 Common Name", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  498.     { { siDEROID, x520CountryName,
  499.   sizeof(x520CountryName) },
  500.   SEC_OID_AVA_COUNTRY_NAME,
  501.   "X520 Country Name", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  502.     { { siDEROID, x520LocalityName,
  503.   sizeof(x520LocalityName) },
  504.   SEC_OID_AVA_LOCALITY,
  505.   "X520 Locality Name", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  506.     { { siDEROID, x520StateOrProvinceName,
  507.   sizeof(x520StateOrProvinceName) },
  508.   SEC_OID_AVA_STATE_OR_PROVINCE,
  509.   "X520 State Or Province Name", CKM_INVALID_MECHANISM,
  510.   INVALID_CERT_EXTENSION },
  511.     { { siDEROID, x520OrgName,
  512.   sizeof(x520OrgName) },
  513.   SEC_OID_AVA_ORGANIZATION_NAME,
  514.   "X520 Organization Name", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  515.     { { siDEROID, x520OrgUnitName,
  516.   sizeof(x520OrgUnitName) },
  517.   SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME,
  518.   "X520 Organizational Unit Name", CKM_INVALID_MECHANISM,
  519.   INVALID_CERT_EXTENSION },
  520.     { { siDEROID, x520DnQualifier,
  521.   sizeof(x520DnQualifier) },
  522.   SEC_OID_AVA_DN_QUALIFIER,
  523.   "X520 DN Qualifier", CKM_INVALID_MECHANISM,
  524.   INVALID_CERT_EXTENSION },
  525.     { { siDEROID, rfc2247DomainComponent,
  526.   sizeof(rfc2247DomainComponent), },
  527.   SEC_OID_AVA_DC,
  528.   "RFC 2247 Domain Component", CKM_INVALID_MECHANISM,
  529.   INVALID_CERT_EXTENSION },
  530.     { { siDEROID, nsTypeGIF,
  531.   sizeof(nsTypeGIF) },
  532.   SEC_OID_NS_TYPE_GIF,
  533.   "GIF", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  534.     { { siDEROID, nsTypeJPEG,
  535.   sizeof(nsTypeJPEG) },
  536.   SEC_OID_NS_TYPE_JPEG,
  537.   "JPEG", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  538.     { { siDEROID, nsTypeURL,
  539.   sizeof(nsTypeURL) },
  540.   SEC_OID_NS_TYPE_URL,
  541.   "URL", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  542.     { { siDEROID, nsTypeHTML,
  543.   sizeof(nsTypeHTML) },
  544.   SEC_OID_NS_TYPE_HTML,
  545.   "HTML", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  546.     { { siDEROID, nsTypeCertSeq,
  547.   sizeof(nsTypeCertSeq) },
  548.   SEC_OID_NS_TYPE_CERT_SEQUENCE,
  549.   "Certificate Sequence", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  550.     { { siDEROID, missiCertKEADSSOld, sizeof(missiCertKEADSSOld) },
  551.           SEC_OID_MISSI_KEA_DSS_OLD, "MISSI KEA and DSS Algorithm (Old)",
  552.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  553.     { { siDEROID, missiCertDSSOld, sizeof(missiCertDSSOld) },
  554.           SEC_OID_MISSI_DSS_OLD, "MISSI DSS Algorithm (Old)",
  555.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION  },
  556.     { { siDEROID, missiCertKEADSS, sizeof(missiCertKEADSS) },
  557.           SEC_OID_MISSI_KEA_DSS, "MISSI KEA and DSS Algorithm",
  558.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION  },
  559.     { { siDEROID, missiCertDSS, sizeof(missiCertDSS) },
  560.           SEC_OID_MISSI_DSS, "MISSI DSS Algorithm",
  561.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION  },
  562.     { { siDEROID, missiCertKEA, sizeof(missiCertKEA) },
  563.           SEC_OID_MISSI_KEA, "MISSI KEA Algorithm",
  564.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION  },
  565.     { { siDEROID, missiCertAltKEA, sizeof(missiCertAltKEA) },
  566.           SEC_OID_MISSI_ALT_KEA, "MISSI Alternate KEA Algorithm",
  567.           CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION  },
  568.     /* Netscape private extensions */
  569.     { { siDEROID, nsCertExtNetscapeOK,
  570.   sizeof(nsCertExtNetscapeOK) },
  571.   SEC_OID_NS_CERT_EXT_NETSCAPE_OK,
  572.   "Netscape says this cert is OK",
  573.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  574.     { { siDEROID, nsCertExtIssuerLogo,
  575.   sizeof(nsCertExtIssuerLogo) },
  576.   SEC_OID_NS_CERT_EXT_ISSUER_LOGO,
  577.   "Certificate Issuer Logo",
  578.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  579.     { { siDEROID, nsCertExtSubjectLogo,
  580.   sizeof(nsCertExtSubjectLogo) },
  581.   SEC_OID_NS_CERT_EXT_SUBJECT_LOGO,
  582.   "Certificate Subject Logo",
  583.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  584.     { { siDEROID, nsExtCertType,
  585.   sizeof(nsExtCertType) },
  586.   SEC_OID_NS_CERT_EXT_CERT_TYPE,
  587.   "Certificate Type",
  588.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  589.     { { siDEROID, nsExtBaseURL,
  590.   sizeof(nsExtBaseURL) },
  591.   SEC_OID_NS_CERT_EXT_BASE_URL,
  592.   "Certificate Extension Base URL",
  593.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  594.     { { siDEROID, nsExtRevocationURL,
  595.   sizeof(nsExtRevocationURL) },
  596.   SEC_OID_NS_CERT_EXT_REVOCATION_URL,
  597.   "Certificate Revocation URL",
  598.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  599.     { { siDEROID, nsExtCARevocationURL,
  600.   sizeof(nsExtCARevocationURL) },
  601.   SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL,
  602.   "Certificate Authority Revocation URL",
  603.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  604.     { { siDEROID, nsExtCACRLURL,
  605.   sizeof(nsExtCACRLURL) },
  606.   SEC_OID_NS_CERT_EXT_CA_CRL_URL,
  607.   "Certificate Authority CRL Download URL",
  608.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  609.     { { siDEROID, nsExtCACertURL,
  610.   sizeof(nsExtCACertURL) },
  611.   SEC_OID_NS_CERT_EXT_CA_CERT_URL,
  612.   "Certificate Authority Certificate Download URL",
  613.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  614.     { { siDEROID, nsExtCertRenewalURL,
  615.   sizeof(nsExtCertRenewalURL) },
  616.   SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL,
  617.   "Certificate Renewal URL", CKM_INVALID_MECHANISM,
  618.           SUPPORTED_CERT_EXTENSION }, 
  619.     { { siDEROID, nsExtCAPolicyURL,
  620.   sizeof(nsExtCAPolicyURL) },
  621.   SEC_OID_NS_CERT_EXT_CA_POLICY_URL,
  622.   "Certificate Authority Policy URL",
  623.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  624.     { { siDEROID, nsExtHomepageURL,
  625.   sizeof(nsExtHomepageURL) },
  626.   SEC_OID_NS_CERT_EXT_HOMEPAGE_URL,
  627.   "Certificate Homepage URL", CKM_INVALID_MECHANISM,
  628.   UNSUPPORTED_CERT_EXTENSION },
  629.     { { siDEROID, nsExtEntityLogo,
  630.   sizeof(nsExtEntityLogo) },
  631.   SEC_OID_NS_CERT_EXT_ENTITY_LOGO,
  632.   "Certificate Entity Logo", CKM_INVALID_MECHANISM,
  633.   UNSUPPORTED_CERT_EXTENSION },
  634.     { { siDEROID, nsExtUserPicture,
  635.   sizeof(nsExtUserPicture) },
  636.   SEC_OID_NS_CERT_EXT_USER_PICTURE,
  637.   "Certificate User Picture", CKM_INVALID_MECHANISM,
  638.   UNSUPPORTED_CERT_EXTENSION },
  639.     { { siDEROID, nsExtSSLServerName,
  640.   sizeof(nsExtSSLServerName) },
  641.   SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME,
  642.   "Certificate SSL Server Name", CKM_INVALID_MECHANISM,
  643.   SUPPORTED_CERT_EXTENSION },
  644.     { { siDEROID, nsExtComment,
  645.   sizeof(nsExtComment) },
  646.   SEC_OID_NS_CERT_EXT_COMMENT,
  647.   "Certificate Comment", CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  648.     { { siDEROID, nsExtLostPasswordURL,
  649.           sizeof(nsExtLostPasswordURL) },
  650.           SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL,
  651.           "Lost Password URL", CKM_INVALID_MECHANISM,
  652.           SUPPORTED_CERT_EXTENSION },
  653.     { { siDEROID, nsExtCertRenewalTime, 
  654. sizeof(nsExtCertRenewalTime) },
  655. SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME, 
  656. "Certificate Renewal Time", CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  657.     { { siDEROID, nsKeyUsageGovtApproved,
  658.   sizeof(nsKeyUsageGovtApproved) },
  659.   SEC_OID_NS_KEY_USAGE_GOVT_APPROVED,
  660.   "Strong Crypto Export Approved",
  661.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  662.     /* x.509 v3 certificate extensions */
  663.     { { siDEROID, x509SubjectDirectoryAttr, sizeof(x509SubjectDirectoryAttr) },
  664.   SEC_OID_X509_SUBJECT_DIRECTORY_ATTR,
  665.   "Certificate Subject Directory Attributes",
  666.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION},
  667.     { { siDEROID, x509SubjectKeyID, sizeof(x509SubjectKeyID) },
  668.   SEC_OID_X509_SUBJECT_KEY_ID, "Certificate Subject Key ID",
  669.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  670.     { { siDEROID, x509KeyUsage, sizeof(x509KeyUsage) },
  671.   SEC_OID_X509_KEY_USAGE, "Certificate Key Usage",
  672.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  673.     { { siDEROID, x509PrivateKeyUsagePeriod,
  674.   sizeof(x509PrivateKeyUsagePeriod) },
  675.   SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD,
  676.   "Certificate Private Key Usage Period",
  677.           CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  678.     { { siDEROID, x509SubjectAltName, sizeof(x509SubjectAltName) },
  679.   SEC_OID_X509_SUBJECT_ALT_NAME, "Certificate Subject Alt Name",
  680.           CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  681.     { { siDEROID, x509IssuerAltName, sizeof(x509IssuerAltName) },
  682.   SEC_OID_X509_ISSUER_ALT_NAME, "Certificate Issuer Alt Name",
  683.           CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  684.     { { siDEROID, x509BasicConstraints, sizeof(x509BasicConstraints) },
  685.   SEC_OID_X509_BASIC_CONSTRAINTS, "Certificate Basic Constraints",
  686.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  687.     { { siDEROID, x509NameConstraints, sizeof(x509NameConstraints) },
  688.   SEC_OID_X509_NAME_CONSTRAINTS, "Certificate Name Constraints",
  689.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  690.     { { siDEROID, x509CRLDistPoints, sizeof(x509CRLDistPoints) },
  691.   SEC_OID_X509_CRL_DIST_POINTS, "CRL Distribution Points",
  692.   CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  693.     { { siDEROID, x509CertificatePolicies, sizeof(x509CertificatePolicies) },
  694.   SEC_OID_X509_CERTIFICATE_POLICIES,
  695.   "Certificate Policies",
  696.           CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  697.     { { siDEROID, x509PolicyMappings, sizeof(x509PolicyMappings) },
  698.   SEC_OID_X509_POLICY_MAPPINGS, "Certificate Policy Mappings",
  699.           CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  700.     { { siDEROID, x509PolicyConstraints, sizeof(x509PolicyConstraints) },
  701.   SEC_OID_X509_POLICY_CONSTRAINTS, "Certificate Policy Constraints",
  702.           CKM_INVALID_MECHANISM, UNSUPPORTED_CERT_EXTENSION },
  703.     { { siDEROID, x509AuthKeyID, sizeof(x509AuthKeyID) },
  704.   SEC_OID_X509_AUTH_KEY_ID, "Certificate Authority Key Identifier",
  705.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  706.     { { siDEROID, x509ExtKeyUsage, sizeof(x509ExtKeyUsage) },
  707.   SEC_OID_X509_EXT_KEY_USAGE, "Extended Key Usage",
  708.   CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  709.     { { siDEROID, x509AuthInfoAccess, sizeof(x509AuthInfoAccess) },
  710.           SEC_OID_X509_AUTH_INFO_ACCESS, "Authority Information Access",
  711.           CKM_INVALID_MECHANISM, SUPPORTED_CERT_EXTENSION },
  712.     /* x.509 v3 CRL extensions */
  713.     { { siDEROID, x509CrlNumber, sizeof(x509CrlNumber) },
  714.   SEC_OID_X509_CRL_NUMBER, "CRL Number", CKM_INVALID_MECHANISM,
  715.   SUPPORTED_CERT_EXTENSION },
  716.     { { siDEROID, x509ReasonCode, sizeof(x509ReasonCode) },
  717.   SEC_OID_X509_REASON_CODE, "CRL reason code", CKM_INVALID_MECHANISM,
  718.   SUPPORTED_CERT_EXTENSION },
  719.     { { siDEROID, x509InvalidDate, sizeof(x509InvalidDate) },
  720.   SEC_OID_X509_INVALID_DATE, "Invalid Date", CKM_INVALID_MECHANISM,
  721.   SUPPORTED_CERT_EXTENSION },
  722.   
  723.     { { siDEROID, x500RSAEncryption, sizeof(x500RSAEncryption) },
  724.   SEC_OID_X500_RSA_ENCRYPTION,
  725.   "X500 RSA Encryption", CKM_RSA_X_509, INVALID_CERT_EXTENSION },
  726.     /* added for alg 1485 */
  727.     { { siDEROID, rfc1274Uid,
  728.   sizeof(rfc1274Uid) },
  729.   SEC_OID_RFC1274_UID,
  730.   "RFC1274 User Id", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  731.     { { siDEROID, rfc1274Mail,
  732.   sizeof(rfc1274Uid) },
  733.   SEC_OID_RFC1274_MAIL,
  734.   "RFC1274 E-mail Address", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  735.     /* pkcs 12 additions */
  736.     { { siDEROID, pkcs12, sizeof(pkcs12) },
  737.   SEC_OID_PKCS12,
  738.   "PKCS #12", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  739.     { { siDEROID, pkcs12ModeIDs, sizeof(pkcs12ModeIDs) },
  740.   SEC_OID_PKCS12_MODE_IDS,
  741.   "PKCS #12 Mode IDs", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  742.     { { siDEROID, pkcs12ESPVKIDs, sizeof(pkcs12ESPVKIDs) },
  743.   SEC_OID_PKCS12_ESPVK_IDS,
  744.   "PKCS #12 ESPVK IDs", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  745.     { { siDEROID, pkcs12BagIDs, sizeof(pkcs12BagIDs) },
  746.   SEC_OID_PKCS12_BAG_IDS,
  747.   "PKCS #12 Bag IDs", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  748.     { { siDEROID, pkcs12CertBagIDs, sizeof(pkcs12CertBagIDs) },
  749.   SEC_OID_PKCS12_CERT_BAG_IDS,
  750.   "PKCS #12 Cert Bag IDs", CKM_INVALID_MECHANISM,
  751.   INVALID_CERT_EXTENSION },
  752.     { { siDEROID, pkcs12OIDs, sizeof(pkcs12OIDs) },
  753.   SEC_OID_PKCS12_OIDS,
  754.   "PKCS #12 OIDs", CKM_INVALID_MECHANISM,
  755.   INVALID_CERT_EXTENSION },
  756.     { { siDEROID, pkcs12PBEIDs, sizeof(pkcs12PBEIDs) },
  757.   SEC_OID_PKCS12_PBE_IDS,
  758.   "PKCS #12 PBE IDs", CKM_INVALID_MECHANISM,
  759.   INVALID_CERT_EXTENSION },
  760.     { { siDEROID, pkcs12SignatureIDs, sizeof(pkcs12SignatureIDs) },
  761.   SEC_OID_PKCS12_SIGNATURE_IDS,
  762.   "PKCS #12 Signature IDs", CKM_INVALID_MECHANISM,
  763.   INVALID_CERT_EXTENSION },
  764.     { { siDEROID, pkcs12EnvelopingIDs, sizeof(pkcs12EnvelopingIDs) },
  765.   SEC_OID_PKCS12_ENVELOPING_IDS,
  766.   "PKCS #12 Enveloping IDs", CKM_INVALID_MECHANISM,
  767.   INVALID_CERT_EXTENSION },
  768.     { { siDEROID, pkcs12PKCS8KeyShrouding, 
  769.      sizeof(pkcs12PKCS8KeyShrouding) },
  770.   SEC_OID_PKCS12_PKCS8_KEY_SHROUDING,
  771.   "PKCS #12 Key Shrouding", CKM_INVALID_MECHANISM,
  772.   INVALID_CERT_EXTENSION },
  773.     { { siDEROID, pkcs12KeyBagID, 
  774.      sizeof(pkcs12KeyBagID) },
  775.   SEC_OID_PKCS12_KEY_BAG_ID,
  776.   "PKCS #12 Key Bag ID", CKM_INVALID_MECHANISM,
  777.   INVALID_CERT_EXTENSION },
  778.     { { siDEROID, pkcs12CertAndCRLBagID, 
  779.      sizeof(pkcs12CertAndCRLBagID) },
  780.   SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID,
  781.   "PKCS #12 Cert And CRL Bag ID", CKM_INVALID_MECHANISM,
  782.   INVALID_CERT_EXTENSION },
  783.     { { siDEROID, pkcs12SecretBagID, 
  784.      sizeof(pkcs12SecretBagID) },
  785.   SEC_OID_PKCS12_SECRET_BAG_ID,
  786.   "PKCS #12 Secret Bag ID", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  787.     { { siDEROID, pkcs12X509CertCRLBag, 
  788.      sizeof(pkcs12X509CertCRLBag) },
  789.   SEC_OID_PKCS12_X509_CERT_CRL_BAG,
  790.   "PKCS #12 X509 Cert CRL Bag", CKM_INVALID_MECHANISM,
  791.   INVALID_CERT_EXTENSION },
  792.     { { siDEROID, pkcs12SDSICertBag, 
  793.      sizeof(pkcs12SDSICertBag) },
  794.   SEC_OID_PKCS12_SDSI_CERT_BAG,
  795.   "PKCS #12 SDSI Cert Bag", CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  796.     { { siDEROID, pkcs12PBEWithSha1And128BitRC4, 
  797.      sizeof(pkcs12PBEWithSha1And128BitRC4) },
  798.   SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4,
  799.   "PKCS #12 PBE With Sha1 and 128 Bit RC4", 
  800.   CKM_NETSCAPE_PBE_SHA1_128_BIT_RC4, INVALID_CERT_EXTENSION },
  801.     { { siDEROID, pkcs12PBEWithSha1And40BitRC4, 
  802.      sizeof(pkcs12PBEWithSha1And40BitRC4) },
  803.   SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4,
  804.   "PKCS #12 PBE With Sha1 and 40 Bit RC4", 
  805.   CKM_NETSCAPE_PBE_SHA1_40_BIT_RC4, INVALID_CERT_EXTENSION },
  806.     { { siDEROID, pkcs12PBEWithSha1AndTripleDESCBC, 
  807.      sizeof(pkcs12PBEWithSha1AndTripleDESCBC) },
  808.   SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC,
  809.   "PKCS #12 PBE With Sha1 and Triple DES CBC", 
  810.   CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC, INVALID_CERT_EXTENSION },
  811.     { { siDEROID, pkcs12PBEWithSha1And128BitRC2CBC, 
  812.      sizeof(pkcs12PBEWithSha1And128BitRC2CBC) },
  813.   SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC,
  814.   "PKCS #12 PBE With Sha1 and 128 Bit RC2 CBC", 
  815.   CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC, INVALID_CERT_EXTENSION },
  816.     { { siDEROID, pkcs12PBEWithSha1And40BitRC2CBC, 
  817.      sizeof(pkcs12PBEWithSha1And40BitRC2CBC) },
  818.   SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC,
  819.   "PKCS #12 PBE With Sha1 and 40 Bit RC2 CBC", 
  820.   CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC, INVALID_CERT_EXTENSION },
  821.     { { siDEROID, pkcs12RSAEncryptionWith128BitRC4, 
  822.      sizeof(pkcs12RSAEncryptionWith128BitRC4) },
  823.   SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4,
  824.   "PKCS #12 RSA Encryption with 128 Bit RC4",
  825.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  826.     { { siDEROID, pkcs12RSAEncryptionWith40BitRC4, 
  827.      sizeof(pkcs12RSAEncryptionWith40BitRC4) },
  828.   SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4,
  829.   "PKCS #12 RSA Encryption with 40 Bit RC4",
  830.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  831.     { { siDEROID, pkcs12RSAEncryptionWithTripleDES, 
  832.      sizeof(pkcs12RSAEncryptionWithTripleDES) },
  833.   SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES,
  834.   "PKCS #12 RSA Encryption with Triple DES",
  835.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  836.     { { siDEROID, pkcs12RSASignatureWithSHA1Digest, 
  837.      sizeof(pkcs12RSASignatureWithSHA1Digest) },
  838.   SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST,
  839.   "PKCS #12 RSA Encryption with Triple DES",
  840.   CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  841.     /* DSA signatures */
  842.     { { siDEROID, ansix9DSASignature, sizeof(ansix9DSASignature) },
  843.         SEC_OID_ANSIX9_DSA_SIGNATURE,
  844. "ANSI X9.57 DSA Signature", CKM_DSA,
  845. INVALID_CERT_EXTENSION },
  846.     { { siDEROID, ansix9DSASignaturewithSHA1Digest,
  847. sizeof(ansix9DSASignaturewithSHA1Digest) },
  848.         SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST,
  849. "ANSI X9.57 DSA Signature with SHA1 Digest", CKM_DSA_SHA1,
  850. INVALID_CERT_EXTENSION },
  851.     { { siDEROID, bogusDSASignaturewithSHA1Digest,
  852. sizeof(bogusDSASignaturewithSHA1Digest) },
  853.         SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST,
  854. "FORTEZZA DSA Signature with SHA1 Digest", CKM_DSA_SHA1,
  855. INVALID_CERT_EXTENSION },
  856.     /* verisign oids */
  857.     { { siDEROID, verisignUserNotices,
  858. sizeof(verisignUserNotices) },
  859.         SEC_OID_VERISIGN_USER_NOTICES,
  860. "Verisign User Notices", CKM_INVALID_MECHANISM,
  861. INVALID_CERT_EXTENSION },
  862.     /* pkix oids */
  863.     { { siDEROID, pkixCPSPointerQualifier,
  864. sizeof(pkixCPSPointerQualifier) },
  865.         SEC_OID_PKIX_CPS_POINTER_QUALIFIER,
  866. "PKIX CPS Pointer Qualifier", CKM_INVALID_MECHANISM,
  867. INVALID_CERT_EXTENSION },
  868.     { { siDEROID, pkixUserNoticeQualifier,
  869. sizeof(pkixUserNoticeQualifier) },
  870.         SEC_OID_PKIX_USER_NOTICE_QUALIFIER,
  871. "PKIX User Notice Qualifier", CKM_INVALID_MECHANISM,
  872. INVALID_CERT_EXTENSION },
  873.     { { siDEROID, pkixOCSP, sizeof(pkixOCSP), },
  874. SEC_OID_PKIX_OCSP,
  875. "PKIX Online Certificate Status Protocol", CKM_INVALID_MECHANISM,
  876. INVALID_CERT_EXTENSION },
  877.     { { siDEROID, pkixOCSPBasicResponse, sizeof(pkixOCSPBasicResponse), },
  878. SEC_OID_PKIX_OCSP_BASIC_RESPONSE,
  879. "OCSP Basic Response", CKM_INVALID_MECHANISM,
  880. INVALID_CERT_EXTENSION },
  881.     { { siDEROID, pkixOCSPNonce, sizeof(pkixOCSPNonce), },
  882. SEC_OID_PKIX_OCSP_NONCE,
  883. "OCSP Nonce Extension", CKM_INVALID_MECHANISM,
  884. INVALID_CERT_EXTENSION },
  885.     { { siDEROID, pkixOCSPCRL, sizeof(pkixOCSPCRL), },
  886. SEC_OID_PKIX_OCSP_CRL,
  887. "OCSP CRL Reference Extension", CKM_INVALID_MECHANISM,
  888. INVALID_CERT_EXTENSION },
  889.     { { siDEROID, pkixOCSPResponse, sizeof(pkixOCSPResponse), },
  890. SEC_OID_PKIX_OCSP_RESPONSE,
  891. "OCSP Response Types Extension", CKM_INVALID_MECHANISM,
  892. INVALID_CERT_EXTENSION },
  893.     { { siDEROID, pkixOCSPNoCheck, sizeof(pkixOCSPNoCheck) },
  894. SEC_OID_PKIX_OCSP_NO_CHECK,
  895. "OCSP No Check Extension", CKM_INVALID_MECHANISM, 
  896. SUPPORTED_CERT_EXTENSION },
  897.     { { siDEROID, pkixOCSPArchiveCutoff, sizeof(pkixOCSPArchiveCutoff) },
  898. SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF,
  899. "OCSP Archive Cutoff Extension", CKM_INVALID_MECHANISM,
  900. INVALID_CERT_EXTENSION },
  901.     { { siDEROID, pkixOCSPServiceLocator, sizeof(pkixOCSPServiceLocator) },
  902. SEC_OID_PKIX_OCSP_SERVICE_LOCATOR,
  903. "OCSP Service Locator Extension", CKM_INVALID_MECHANISM,
  904. INVALID_CERT_EXTENSION },
  905.     { { siDEROID, pkixRegCtrlRegToken,
  906. sizeof (pkixRegCtrlRegToken) },
  907.         SEC_OID_PKIX_REGCTRL_REGTOKEN,
  908.         "PKIX CRMF Registration Control, Registration Token", 
  909.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  910.     { { siDEROID, pkixRegCtrlAuthenticator,
  911. sizeof (pkixRegCtrlAuthenticator) },
  912.         SEC_OID_PKIX_REGCTRL_AUTHENTICATOR,
  913.         "PKIX CRMF Registration Control, Registration Authenticator", 
  914.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION },
  915.     { { siDEROID, pkixRegCtrlPKIPubInfo,
  916. sizeof (pkixRegCtrlPKIPubInfo) },
  917.         SEC_OID_PKIX_REGCTRL_PKIPUBINFO,
  918.         "PKIX CRMF Registration Control, PKI Publication Info", 
  919.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  920.     { { siDEROID, pkixRegCtrlPKIArchOptions,
  921. sizeof (pkixRegCtrlPKIArchOptions) },
  922.         SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS,
  923.         "PKIX CRMF Registration Control, PKI Archive Options", 
  924.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  925.     { { siDEROID, pkixRegCtrlOldCertID,
  926. sizeof (pkixRegCtrlOldCertID) },
  927.         SEC_OID_PKIX_REGCTRL_OLD_CERT_ID,
  928.         "PKIX CRMF Registration Control, Old Certificate ID", 
  929.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  930.     { { siDEROID, pkixRegCtrlProtEncKey,
  931. sizeof (pkixRegCtrlProtEncKey) },
  932.         SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY,
  933.         "PKIX CRMF Registration Control, Protocol Encryption Key", 
  934.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  935.     { { siDEROID, pkixRegInfoUTF8Pairs,
  936. sizeof (pkixRegInfoUTF8Pairs) },
  937.         SEC_OID_PKIX_REGINFO_UTF8_PAIRS,
  938.         "PKIX CRMF Registration Info, UTF8 Pairs", 
  939.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  940.     { { siDEROID, pkixRegInfoCertReq,
  941. sizeof (pkixRegInfoCertReq) },
  942.         SEC_OID_PKIX_REGINFO_CERT_REQUEST,
  943.         "PKIX CRMF Registration Info, Certificate Request", 
  944.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  945.     { { siDEROID, pkixExtendedKeyUsageServerAuth,
  946. sizeof (pkixExtendedKeyUsageServerAuth) },
  947.         SEC_OID_EXT_KEY_USAGE_SERVER_AUTH,
  948.         "TLS Web Server Authentication Certificate",
  949.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  950.     { { siDEROID, pkixExtendedKeyUsageClientAuth,
  951. sizeof (pkixExtendedKeyUsageClientAuth) },
  952.         SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH,
  953.         "TLS Web Client Authentication Certificate",
  954.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  955.     { { siDEROID, pkixExtendedKeyUsageCodeSign,
  956. sizeof (pkixExtendedKeyUsageCodeSign) },
  957.         SEC_OID_EXT_KEY_USAGE_CODE_SIGN,
  958.         "Code Signing Certificate",
  959.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  960.     { { siDEROID, pkixExtendedKeyUsageEMailProtect,
  961. sizeof (pkixExtendedKeyUsageEMailProtect) },
  962.         SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT,
  963.         "E-Mail Protection Certificate",
  964.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  965.     { { siDEROID, pkixExtendedKeyUsageTimeStamp,
  966. sizeof (pkixExtendedKeyUsageTimeStamp) },
  967.         SEC_OID_EXT_KEY_USAGE_TIME_STAMP,
  968.         "Time Stamping Certifcate",
  969.         CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  970.     { { siDEROID, pkixOCSPResponderExtendedKeyUsage,
  971.   sizeof (pkixOCSPResponderExtendedKeyUsage) },
  972.           SEC_OID_OCSP_RESPONDER,
  973.           "OCSP Responder Certificate",
  974.           CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION},
  975.     /* Netscape Algorithm OIDs */
  976.     { { siDEROID, netscapeSMimeKEA,
  977. sizeof(netscapeSMimeKEA) },
  978.         SEC_OID_NETSCAPE_SMIME_KEA,
  979. "Netscape S/MIME KEA", CKM_INVALID_MECHANISM,
  980. INVALID_CERT_EXTENSION },
  981.       /* Skipjack OID -- ### mwelch temporary */
  982.     { { siDEROID, skipjackCBC,
  983. sizeof(skipjackCBC) },
  984.         SEC_OID_FORTEZZA_SKIPJACK,
  985. "Skipjack CBC64", CKM_SKIPJACK_CBC64,
  986. INVALID_CERT_EXTENSION },
  987.     /* pkcs12 v2 oids */
  988.     { { siDEROID, pkcs12V2PBEWithSha1And128BitRC4,
  989. sizeof(pkcs12V2PBEWithSha1And128BitRC4) },
  990.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4,
  991. "PKCS12 V2 PBE With SHA1 And 128 Bit RC4", 
  992. CKM_PBE_SHA1_RC4_128,
  993. INVALID_CERT_EXTENSION },
  994.     { { siDEROID, pkcs12V2PBEWithSha1And40BitRC4,
  995. sizeof(pkcs12V2PBEWithSha1And40BitRC4) },
  996.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4,
  997. "PKCS12 V2 PBE With SHA1 And 40 Bit RC4", 
  998. CKM_PBE_SHA1_RC4_40,
  999. INVALID_CERT_EXTENSION },
  1000.     { { siDEROID, pkcs12V2PBEWithSha1And3KeyTripleDEScbc,
  1001. sizeof(pkcs12V2PBEWithSha1And3KeyTripleDEScbc) },
  1002.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC,
  1003. "PKCS12 V2 PBE With SHA1 And 3KEY Triple DES-cbc", 
  1004. CKM_PBE_SHA1_DES3_EDE_CBC,
  1005. INVALID_CERT_EXTENSION },
  1006.     { { siDEROID, pkcs12V2PBEWithSha1And2KeyTripleDEScbc,
  1007. sizeof(pkcs12V2PBEWithSha1And2KeyTripleDEScbc) },
  1008.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC,
  1009. "PKCS12 V2 PBE With SHA1 And 2KEY Triple DES-cbc", 
  1010. CKM_PBE_SHA1_DES2_EDE_CBC,
  1011. INVALID_CERT_EXTENSION },
  1012.     { { siDEROID, pkcs12V2PBEWithSha1And128BitRC2cbc,
  1013. sizeof(pkcs12V2PBEWithSha1And128BitRC2cbc) },
  1014.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC,
  1015. "PKCS12 V2 PBE With SHA1 And 128 Bit RC2 CBC", 
  1016. CKM_PBE_SHA1_RC2_128_CBC,
  1017. INVALID_CERT_EXTENSION },
  1018.     { { siDEROID, pkcs12V2PBEWithSha1And40BitRC2cbc,
  1019. sizeof(pkcs12V2PBEWithSha1And40BitRC2cbc) },
  1020.         SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC,
  1021. "PKCS12 V2 PBE With SHA1 And 40 Bit RC2 CBC", 
  1022. CKM_PBE_SHA1_RC2_40_CBC,
  1023. INVALID_CERT_EXTENSION },
  1024.     { { siDEROID, pkcs12SafeContentsID, 
  1025.      sizeof(pkcs12SafeContentsID) },
  1026.   SEC_OID_PKCS12_SAFE_CONTENTS_ID,
  1027.   "PKCS #12 Safe Contents ID", CKM_INVALID_MECHANISM,
  1028.   INVALID_CERT_EXTENSION },
  1029.     { { siDEROID, pkcs12PKCS8ShroudedKeyBagID, 
  1030.      sizeof(pkcs12PKCS8ShroudedKeyBagID) },
  1031.   SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID,
  1032.   "PKCS #12 Safe Contents ID", CKM_INVALID_MECHANISM,
  1033.   INVALID_CERT_EXTENSION },
  1034.     { { siDEROID, pkcs12V1KeyBag, 
  1035.      sizeof(pkcs12V1KeyBag) },
  1036.   SEC_OID_PKCS12_V1_KEY_BAG_ID,
  1037.   "PKCS #12 V1 Key Bag", CKM_INVALID_MECHANISM,
  1038.   INVALID_CERT_EXTENSION },
  1039.     { { siDEROID, pkcs12V1PKCS8ShroudedKeyBag, 
  1040.      sizeof(pkcs12V1PKCS8ShroudedKeyBag) },
  1041.   SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID,
  1042.   "PKCS #12 V1 PKCS8 Shrouded Key Bag", CKM_INVALID_MECHANISM,
  1043.   INVALID_CERT_EXTENSION },
  1044.     { { siDEROID, pkcs12V1CertBag, 
  1045.      sizeof(pkcs12V1CertBag) },
  1046.   SEC_OID_PKCS12_V1_CERT_BAG_ID,
  1047.   "PKCS #12 V1 Cert Bag", CKM_INVALID_MECHANISM,
  1048.   INVALID_CERT_EXTENSION },
  1049.     { { siDEROID, pkcs12V1CRLBag, 
  1050.      sizeof(pkcs12V1CRLBag) },
  1051.   SEC_OID_PKCS12_V1_CRL_BAG_ID,
  1052.   "PKCS #12 V1 CRL Bag", CKM_INVALID_MECHANISM,
  1053.   INVALID_CERT_EXTENSION },
  1054.     { { siDEROID, pkcs12V1SecretBag, 
  1055.      sizeof(pkcs12V1SecretBag) },
  1056.   SEC_OID_PKCS12_V1_SECRET_BAG_ID,
  1057.   "PKCS #12 V1 Secret Bag", CKM_INVALID_MECHANISM,
  1058.   INVALID_CERT_EXTENSION },
  1059.     { { siDEROID, pkcs12V1SafeContentsBag, 
  1060.      sizeof(pkcs12V1SafeContentsBag) },
  1061.   SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID,
  1062.   "PKCS #12 V1 Safe Contents Bag", CKM_INVALID_MECHANISM,
  1063.   INVALID_CERT_EXTENSION },
  1064.     { { siDEROID, pkcs9X509Certificate, 
  1065.      sizeof(pkcs9X509Certificate) },
  1066.   SEC_OID_PKCS9_X509_CERT,
  1067.   "PKCS #9 X509 Certificate", CKM_INVALID_MECHANISM,
  1068.   INVALID_CERT_EXTENSION },
  1069.     { { siDEROID, pkcs9SDSICertificate, 
  1070.      sizeof(pkcs9SDSICertificate) },
  1071.   SEC_OID_PKCS9_SDSI_CERT,
  1072.   "PKCS #9 SDSI Certificate", CKM_INVALID_MECHANISM,
  1073.   INVALID_CERT_EXTENSION },
  1074.     { { siDEROID, pkcs9X509CRL, 
  1075.      sizeof(pkcs9X509CRL) },
  1076.   SEC_OID_PKCS9_X509_CRL,
  1077.   "PKCS #9 X509 CRL", CKM_INVALID_MECHANISM,
  1078.   INVALID_CERT_EXTENSION },
  1079.     { { siDEROID, pkcs9FriendlyName, 
  1080.      sizeof(pkcs9FriendlyName) },
  1081.   SEC_OID_PKCS9_FRIENDLY_NAME,
  1082.   "PKCS #9 Friendly Name", CKM_INVALID_MECHANISM,
  1083.   INVALID_CERT_EXTENSION },
  1084.     { { siDEROID, pkcs9LocalKeyID, 
  1085.      sizeof(pkcs9LocalKeyID) },
  1086.   SEC_OID_PKCS9_LOCAL_KEY_ID,
  1087.   "PKCS #9 Local Key ID", CKM_INVALID_MECHANISM,
  1088.   INVALID_CERT_EXTENSION }, 
  1089.     { { siDEROID, pkcs12KeyUsageAttr,
  1090. sizeof(pkcs12KeyUsageAttr) },
  1091.   SEC_OID_PKCS12_KEY_USAGE,
  1092.   "PKCS 12 Key Usage", CKM_INVALID_MECHANISM,
  1093.   INVALID_CERT_EXTENSION },
  1094.     { { siDEROID, dhPublicKey,
  1095. sizeof(dhPublicKey) },
  1096.   SEC_OID_X942_DIFFIE_HELMAN_KEY,
  1097.   "Diffie-Helman Public Key", CKM_DH_PKCS_DERIVE,
  1098.   INVALID_CERT_EXTENSION },
  1099.     { { siDEROID, netscapeNickname,
  1100. sizeof(netscapeNickname) },
  1101.   SEC_OID_NETSCAPE_NICKNAME,
  1102.   "Netscape Nickname", CKM_INVALID_MECHANISM,
  1103.   INVALID_CERT_EXTENSION },
  1104.     /* Cert Server specific OIDs */
  1105.     { { siDEROID, netscapeRecoveryRequest,
  1106.         sizeof(netscapeRecoveryRequest) },
  1107.         SEC_OID_NETSCAPE_RECOVERY_REQUEST,
  1108.         "Recovery Request OID", CKM_INVALID_MECHANISM,
  1109.         INVALID_CERT_EXTENSION }, 
  1110.     { { siDEROID, nsExtAIACertRenewal,
  1111.         sizeof(nsExtAIACertRenewal) },
  1112.         SEC_OID_CERT_RENEWAL_LOCATOR,
  1113.         "Certificate Renewal Locator OID", CKM_INVALID_MECHANISM,
  1114.         INVALID_CERT_EXTENSION }, 
  1115.     { { siDEROID, nsExtCertScopeOfUse,
  1116.         sizeof(nsExtCertScopeOfUse) },
  1117.         SEC_OID_NS_CERT_EXT_SCOPE_OF_USE,
  1118.         "Certificate Scope-of-Use Extension", CKM_INVALID_MECHANISM,
  1119.         SUPPORTED_CERT_EXTENSION },
  1120.     /* CMS stuff */
  1121.     { { siDEROID, cmsESDH,
  1122.         sizeof(cmsESDH) },
  1123.         SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN,
  1124.         "Ephemeral-Static Diffie-Hellman", CKM_INVALID_MECHANISM /* XXX */,
  1125.         INVALID_CERT_EXTENSION },
  1126.     { { siDEROID, cms3DESwrap,
  1127.         sizeof(cms3DESwrap) },
  1128.         SEC_OID_CMS_3DES_KEY_WRAP,
  1129.         "CMS 3DES Key Wrap", CKM_INVALID_MECHANISM /* XXX */,
  1130.         INVALID_CERT_EXTENSION },
  1131.     { { siDEROID, cmsRC2wrap,
  1132.         sizeof(cmsRC2wrap) },
  1133.         SEC_OID_CMS_RC2_KEY_WRAP,
  1134.         "CMS RC2 Key Wrap", CKM_INVALID_MECHANISM /* XXX */,
  1135.         INVALID_CERT_EXTENSION },
  1136.     { { siDEROID, smimeEncryptionKeyPreference,
  1137. sizeof(smimeEncryptionKeyPreference) },
  1138. SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE,
  1139. "S/MIME Encryption Key Preference", CKM_INVALID_MECHANISM,
  1140. INVALID_CERT_EXTENSION },
  1141. };
  1142. /*
  1143.  * now the dynamic table. The dynamic table gets build at init time.
  1144.  *  and gets modified if the user loads new crypto modules.
  1145.  */
  1146. static DB *oid_d_hash = 0;
  1147. static SECOidData **secoidDynamicTable = NULL;
  1148. static int secoidDynamicTableSize = 0;
  1149. static int secoidLastDynamicEntry = 0;
  1150. static int secoidLastHashEntry = 0;
  1151. static SECStatus
  1152. secoid_DynamicRehash(void)
  1153. {
  1154.     DBT key;
  1155.     DBT data;
  1156.     int rv;
  1157.     SECOidData *oid;
  1158.     int i;
  1159.     int last = secoidLastDynamicEntry;
  1160.     if (!oid_d_hash) {
  1161.         oid_d_hash = dbopen( 0, O_RDWR | O_CREAT, 0600, DB_HASH, 0 );
  1162.     }
  1163.     if ( !oid_d_hash ) {
  1164. PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1165. return(SECFailure);
  1166.     }
  1167.     for ( i = secoidLastHashEntry; i < last; i++ ) {
  1168. oid = secoidDynamicTable[i];
  1169. /* invalid assert ... guarrenteed not to be true */
  1170. /* PORT_Assert ( oid->offset == i ); */
  1171. key.data = oid->oid.data;
  1172. key.size = oid->oid.len;
  1173. data.data = &oid;
  1174. data.size = sizeof(oid);
  1175. rv = (* oid_d_hash->put)( oid_d_hash, &key, &data, R_NOOVERWRITE );
  1176. if ( rv ) {
  1177.     PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1178.     return(SECFailure);
  1179. }
  1180.     }
  1181.     secoidLastHashEntry = last;
  1182.     return(SECSuccess);
  1183. }
  1184. /*
  1185.  * Lookup a Dynamic OID. Dynamic OID's still change slowly, so it's
  1186.  * cheaper to rehash the table when it changes than it is to do the loop
  1187.  * each time. Worry: what about thread safety here? Global Static data with
  1188.  * no locks.... (sigh).
  1189.  */
  1190. static SECStatus
  1191. secoid_FindDynamic(DBT *key, DBT *data) {
  1192.     if (secoidDynamicTable == NULL) {
  1193. return SECFailure;
  1194.     }
  1195.     if (secoidLastHashEntry != secoidLastDynamicEntry) {
  1196. SECStatus rv = secoid_DynamicRehash();
  1197. if ( rv != SECSuccess ) {
  1198.     return rv;
  1199. }
  1200.     }
  1201.     return (SECStatus)(* oid_d_hash->get)( oid_d_hash, key, data, 0 );
  1202. }
  1203. static SECOidData *
  1204. secoid_FindDynamicByTag(SECOidTag tagnum)
  1205. {
  1206.     int tagNumDiff;
  1207.     if (secoidDynamicTable == NULL) {
  1208. return NULL;
  1209.     }
  1210.     if (tagnum < SEC_OID_TOTAL) {
  1211. return NULL;
  1212.     }
  1213.     tagNumDiff = tagnum - SEC_OID_TOTAL;
  1214.     if (tagNumDiff >= secoidLastDynamicEntry) {
  1215. return NULL;
  1216.     }
  1217.     return(secoidDynamicTable[tagNumDiff]);
  1218. }
  1219. /*
  1220.  * this routine is definately not thread safe. It is only called out
  1221.  * of the UI, or at init time. If we want to call it any other time,
  1222.  * we need to make it thread safe.
  1223.  */
  1224. SECStatus
  1225. SECOID_AddEntry(SECItem *oid, char *description, unsigned long mech) {
  1226.     SECOidData *oiddp = (SECOidData *)PORT_Alloc(sizeof(SECOidData));
  1227.     int last = secoidLastDynamicEntry;
  1228.     int tableSize = secoidDynamicTableSize;
  1229.     int next = last++;
  1230.     SECOidData **newTable = secoidDynamicTable;
  1231.     SECOidData **oldTable = NULL;
  1232.     if (oid == NULL) {
  1233. return SECFailure;
  1234.     }
  1235.     /* fill in oid structure */
  1236.     if (SECITEM_CopyItem(NULL,&oiddp->oid,oid) != SECSuccess) {
  1237. PORT_Free(oiddp);
  1238. return SECFailure;
  1239.     }
  1240.     oiddp->offset = (SECOidTag)(next + SEC_OID_TOTAL);
  1241.     /* may we should just reference the copy passed to us? */
  1242.     oiddp->desc = PORT_Strdup(description);
  1243.     oiddp->mechanism = mech;
  1244.     if (last > tableSize) {
  1245. int oldTableSize = tableSize;
  1246. tableSize += 10;
  1247. oldTable = newTable;
  1248. newTable = (SECOidData **)PORT_ZAlloc(sizeof(SECOidData *)*tableSize);
  1249. if (newTable == NULL) {
  1250.    PORT_Free(oiddp->oid.data);
  1251.    PORT_Free(oiddp);
  1252.    return SECFailure;
  1253. }
  1254. PORT_Memcpy(newTable,oldTable,sizeof(SECOidData *)*oldTableSize);
  1255. PORT_Free(oldTable);
  1256.     }
  1257.     newTable[next] = oiddp;
  1258.     secoidDynamicTable = newTable;
  1259.     secoidDynamicTableSize = tableSize;
  1260.     secoidLastDynamicEntry= last;
  1261.     return SECSuccess;
  1262. }
  1263. /* normal static table processing */
  1264. static DB *oidhash     = NULL;
  1265. static DB *oidmechhash = NULL;
  1266. static SECStatus
  1267. InitOIDHash(void)
  1268. {
  1269.     DBT key;
  1270.     DBT data;
  1271.     int rv;
  1272.     SECOidData *oid;
  1273.     int i;
  1274.     
  1275.     oidhash = dbopen( 0, O_RDWR | O_CREAT, 0600, DB_HASH, 0 );
  1276.     oidmechhash = dbopen( 0, O_RDWR | O_CREAT, 0600, DB_HASH, 0 );
  1277.     if ( !oidhash || !oidmechhash) {
  1278. PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1279.   PORT_Assert(0); /*This function should never fail. */
  1280. return(SECFailure);
  1281.     }
  1282.     for ( i = 0; i < ( sizeof(oids) / sizeof(SECOidData) ); i++ ) {
  1283. oid = &oids[i];
  1284. PORT_Assert ( oid->offset == i );
  1285. key.data = oid->oid.data;
  1286. key.size = oid->oid.len;
  1287. data.data = &oid;
  1288. data.size = sizeof(oid);
  1289. rv = (* oidhash->put)( oidhash, &key, &data, R_NOOVERWRITE );
  1290. if ( rv ) {
  1291.     PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1292.             PORT_Assert(0); /*This function should never fail. */
  1293.     return(SECFailure);
  1294. }
  1295. if ( oid->mechanism != CKM_INVALID_MECHANISM ) {
  1296.     key.data = &oid->mechanism;
  1297.     key.size = sizeof(oid->mechanism);
  1298.     rv = (* oidmechhash->put)( oidmechhash, &key, &data, R_NOOVERWRITE);
  1299.     /* Only error out if the error value returned is not
  1300.      * RET_SPECIAL, ie the mechanism already has a registered 
  1301.      * OID.
  1302.      */
  1303.     if ( rv && rv != RET_SPECIAL) {
  1304.         PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1305.                 PORT_Assert(0); /* This function should never fail. */
  1306. return(SECFailure);
  1307.     }
  1308. }
  1309.     }
  1310.     PORT_Assert (i == SEC_OID_TOTAL);
  1311.     return(SECSuccess);
  1312. }
  1313. SECOidData *
  1314. SECOID_FindOIDByMechanism(unsigned long mechanism)
  1315. {
  1316.     DBT key;
  1317.     DBT data;
  1318.     SECOidData *ret;
  1319.     int rv;
  1320.     if ( !oidhash ) {
  1321.         rv = InitOIDHash();
  1322. if ( rv != SECSuccess ) {
  1323.     PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1324.     return NULL;
  1325. }
  1326.     }
  1327.     key.data = &mechanism;
  1328.     key.size = sizeof(mechanism);
  1329.     rv = (* oidmechhash->get)( oidmechhash, &key, &data, 0 );
  1330.     if ( rv || ( data.size != sizeof(unsigned long) ) ) {
  1331.         PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1332. return NULL;
  1333.     }
  1334.     PORT_Memcpy(&ret, data.data, data.size);
  1335.     return (ret);
  1336. }
  1337. SECOidData *
  1338. SECOID_FindOID(SECItem *oid)
  1339. {
  1340.     DBT key;
  1341.     DBT data;
  1342.     SECOidData *ret;
  1343.     int rv;
  1344.     
  1345.     if ( !oidhash ) {
  1346. rv = InitOIDHash();
  1347. if ( rv != SECSuccess ) {
  1348.     PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1349.     return NULL;
  1350. }
  1351.     }
  1352.     
  1353.     key.data = oid->data;
  1354.     key.size = oid->len;
  1355.     
  1356.     rv = (* oidhash->get)( oidhash, &key, &data, 0 );
  1357.     if ( rv || ( data.size != sizeof(SECOidData*) ) ) {
  1358. rv = secoid_FindDynamic(&key, &data);
  1359. if (rv != SECSuccess) {
  1360.     PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
  1361.     return(0);
  1362. }
  1363.     }
  1364.     PORT_Memcpy(&ret, data.data, data.size);
  1365.     return(ret);
  1366. }
  1367. SECOidTag
  1368. SECOID_FindOIDTag(SECItem *oid)
  1369. {
  1370.     SECOidData *oiddata;
  1371.     oiddata = SECOID_FindOID (oid);
  1372.     if (oiddata == NULL)
  1373. return SEC_OID_UNKNOWN;
  1374.     return oiddata->offset;
  1375. }
  1376. SECOidData *
  1377. SECOID_FindOIDByTag(SECOidTag tagnum)
  1378. {
  1379.     if (tagnum >= SEC_OID_TOTAL) {
  1380. return secoid_FindDynamicByTag(tagnum);
  1381.     }
  1382.     PORT_Assert((unsigned int)tagnum < (sizeof(oids) / sizeof(SECOidData)));
  1383.     return(&oids[tagnum]);
  1384. }
  1385. PRBool SECOID_KnownCertExtenOID (SECItem *extenOid)
  1386. {
  1387.     SECOidData * oidData;
  1388.     oidData = SECOID_FindOID (extenOid);
  1389.     if (oidData == (SECOidData *)NULL)
  1390. return (PR_FALSE);
  1391.     return ((oidData->supportedExtension == SUPPORTED_CERT_EXTENSION) ?
  1392.             PR_TRUE : PR_FALSE);
  1393. }
  1394. const char *
  1395. SECOID_FindOIDTagDescription(SECOidTag tagnum)
  1396. {
  1397.   SECOidData *oidData = SECOID_FindOIDByTag(tagnum);
  1398.   if (!oidData)
  1399.     return 0;
  1400.   else
  1401.     return oidData->desc;
  1402. }