Back to index

lightning-sunbird  0.9+nobinonly
moreoids.c
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2004
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #include "secoid.h"
00038 #include "secmodt.h" /* for CKM_INVALID_MECHANISM */
00039 
00040 #define OI(x) { siDEROID, (unsigned char *)x, sizeof x }
00041 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, mech, ext }
00042 #define ODN(oid,desc) \
00043   { OI(oid), 0, desc, CKM_INVALID_MECHANISM, INVALID_CERT_EXTENSION }
00044 
00045 #define OIDT static const unsigned char
00046 
00047 /* OIW Security Special Interest Group defined algorithms. */
00048 #define OIWSSIG   0x2B, 13, 3, 2
00049 
00050 OIDT  oiwMD5RSA[]    = { OIWSSIG,  3 };
00051 OIDT  oiwDESCBC[]    = { OIWSSIG,  7 };
00052 OIDT  oiwRSAsig[]    = { OIWSSIG, 11 };
00053 OIDT  oiwDSA   []    = { OIWSSIG, 12 };
00054 OIDT  oiwMD5RSAsig[]        = { OIWSSIG, 25 };
00055 OIDT  oiwSHA1  []    = { OIWSSIG, 26 };
00056 OIDT  oiwDSASHA1[]   = { OIWSSIG, 27 };
00057 OIDT  oiwDSASHA1param[] = { OIWSSIG, 28 };
00058 OIDT  oiwSHA1RSA[]   = { OIWSSIG, 29 };
00059 
00060 
00061 /* Microsoft OIDs.  (1 3 6 1 4 1 311 ... )   */
00062 #define MICROSOFT 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37
00063 
00064 OIDT  mCTL[]  = { MICROSOFT, 10, 3, 1 }; /* Cert Trust List signing */
00065 OIDT  mTSS[]  = { MICROSOFT, 10, 3, 2 }; /* Time Stamp Signing */
00066 OIDT  mSGC[]  = { MICROSOFT, 10, 3, 3 }; /* Server gated cryptography */
00067 OIDT  mEFS[]  = { MICROSOFT, 10, 3, 4 }; /* Encrypted File System */
00068 OIDT  mSMIME[]       = { MICROSOFT, 16, 4    }; /* SMIME encryption key prefs */
00069 
00070 OIDT  mECRTT[]       = { MICROSOFT, 20, 2    }; /* Enrollment cert type xtn */
00071 OIDT  mEAGNT[]       = { MICROSOFT, 20, 2, 1 }; /* Enrollment Agent         */
00072 OIDT  mKPSCL[]       = { MICROSOFT, 20, 2, 2 }; /* KP SmartCard Logon       */
00073 OIDT  mNTPN []       = { MICROSOFT, 20, 2, 3 }; /* NT Principal Name        */
00074 OIDT  mCASRV[]       = { MICROSOFT, 21, 1    }; /* CertServ CA version      */
00075 
00076 /* AOL OIDs     (1 3 6 1 4 1 1066 ... )   */
00077 #define AOL 0x2B, 0x06, 0x01, 0x04, 0x01, 0x88, 0x2A
00078 
00079 /* PKIX IDs     (1 3 6 1 5 5 7 ...)  */
00080 #define ID_PKIX 0x2B, 6, 1, 5, 5, 7
00081 /* PKIX Access Descriptors (methods for Authority Info Access Extns) */
00082 #define ID_AD   ID_PKIX, 48
00083 
00084 OIDT  padOCSP[]      = { ID_AD, 1 };  /* OCSP method */
00085 OIDT  padCAissuer[]  = { ID_AD, 2 };  /* URI (for CRL ?) */
00086 OIDT  padTimeStamp[] = { ID_AD, 3 };  /* time stamping */
00087 
00088 /* ISO Cert Extension type OIDs (id-ce)  (2 5 29 ...) */
00089 #define X500                    0x55
00090 #define X520_ATTRIBUTE_TYPE     X500, 0x04
00091 #define X500_ALG                X500, 0x08
00092 #define X500_ALG_ENCRYPTION     X500_ALG, 0x01
00093 #define ID_CE               X500, 29
00094 
00095 OIDT cePlcyObs[] = { ID_CE,  3 };  /* Cert policies, obsolete. */
00096 OIDT cePlcyCns[] = { ID_CE, 36 };  /* Cert policy constraints. */
00097 
00098 /* US Company arc (2 16 840 1 ...) */
00099 #define USCOM        0x60, 0x86, 0x48, 0x01
00100 #define USGOV        USCOM, 0x65
00101 #define USDOD        USGOV, 2
00102 #define ID_INFOSEC   USDOD, 1
00103 
00104 /* Verisign PKI OIDs (2 16 840 1 113733 1 ...) */
00105 #define VERISIGN_PKI USCOM, 0x86, 0xf8, 0x45, 1
00106 #define VERISIGN_XTN VERISIGN_PKI, 6
00107 #define VERISIGN_POL VERISIGN_PKI, 7      /* Cert policies */
00108 #define VERISIGN_TNET VERISIGN_POL, 23    /* Verisign Trust Network */
00109 
00110 OIDT  vcx7[]  = { VERISIGN_XTN, 7 };      /* Cert Extension 7 (?) */
00111 OIDT  vcp1[]  = { VERISIGN_TNET, 1 };     /* class 1 cert policy */
00112 OIDT  vcp2[]  = { VERISIGN_TNET, 2 };     /* class 2 cert policy */
00113 OIDT  vcp3[]  = { VERISIGN_TNET, 3 };     /* class 3 cert policy */
00114 OIDT  vcp4[]  = { VERISIGN_TNET, 4 };     /* class 4 cert policy */
00115 
00116 
00117 /* ------------------------------------------------------------------- */
00118 static const SECOidData oids[] = {
00119 /* OIW Security Special Interest Group OIDs */
00120     ODN( oiwMD5RSA,    "OIWSecSIG MD5 with RSA"),
00121     ODN( oiwDESCBC,    "OIWSecSIG DES CBC"),
00122     ODN( oiwRSAsig,    "OIWSecSIG RSA signature"),
00123     ODN( oiwDSA   ,    "OIWSecSIG DSA"),
00124     ODN( oiwMD5RSAsig,        "OIWSecSIG MD5 with RSA signature"),
00125     ODN( oiwSHA1  ,    "OIWSecSIG SHA1"),
00126     ODN( oiwDSASHA1,   "OIWSecSIG DSA with SHA1"),
00127     ODN( oiwDSASHA1param, "OIWSecSIG DSA with SHA1 with params"),
00128     ODN( oiwSHA1RSA,   "OIWSecSIG MD5 with RSA"),
00129 
00130 /* Microsoft OIDs */
00131     ODN( mCTL,   "Microsoft Cert Trust List signing"), 
00132     ODN( mTSS,   "Microsoft Time Stamp signing"),
00133     ODN( mSGC,   "Microsoft SGC SSL server"),
00134     ODN( mEFS,   "Microsoft Encrypted File System"),
00135     ODN( mSMIME, "Microsoft SMIME preferences"),
00136     ODN( mECRTT, "Microsoft Enrollment Cert Type Extension"),
00137     ODN( mEAGNT, "Microsoft Enrollment Agent"),
00138     ODN( mKPSCL, "Microsoft KP SmartCard Logon"),
00139     ODN( mNTPN,  "Microsoft NT Principal Name"),
00140     ODN( mCASRV, "Microsoft CertServ CA version"),
00141 
00142 /* PKIX OIDs */
00143     ODN( padOCSP,    "PKIX OCSP method"),
00144     ODN( padCAissuer,       "PKIX CA Issuer method"),
00145     ODN( padTimeStamp,      "PKIX Time Stamping method"),
00146 
00147 /* ID_CE OIDs. */
00148     ODN( cePlcyObs,  "Certificate Policies (Obsolete)"),
00149     ODN( cePlcyCns,  "Certificate Policy Constraints"),
00150 
00151 /* Verisign OIDs. */
00152     ODN( vcx7,              "Verisign Cert Extension 7 (?)"),
00153     ODN( vcp1,              "Verisign Class 1 Certificate Policy"),
00154     ODN( vcp2,              "Verisign Class 2 Certificate Policy"),
00155     ODN( vcp3,              "Verisign Class 3 Certificate Policy"),
00156     ODN( vcp4,              "Verisign Class 4 Certificate Policy"),
00157 
00158 };
00159 
00160 static const unsigned int numOids = (sizeof oids) / (sizeof oids[0]);
00161 
00162 SECStatus
00163 SECU_RegisterDynamicOids(void)
00164 {
00165     unsigned int i;
00166     SECStatus rv = SECSuccess;
00167 
00168     for (i = 0; i < numOids; ++i) {
00169        SECOidTag tag = SECOID_AddEntry(&oids[i]);
00170        if (tag == SEC_OID_UNKNOWN) {
00171            rv = SECFailure;
00172 #ifdef DEBUG_DYN_OIDS
00173            fprintf(stderr, "Add OID[%d] failed\n", i);
00174        } else {
00175            fprintf(stderr, "Add OID[%d] returned tag %d\n", i, tag);
00176 #endif
00177        }
00178     }
00179     return rv;
00180 }