]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_x509_cl/lib/DecodedItem.cpp
   2  * Copyright (c) 2002,2011,2014 Apple Inc. All Rights Reserved. 
   4  * The contents of this file constitute Original Code as defined in and are 
   5  * subject to the Apple Public Source License Version 1.2 (the 'License'). 
   6  * You may not use this file except in compliance with the License. Please obtain 
   7  * a copy of the License at http://www.apple.com/publicsource and read it before 
  10  * This Original Code and all software distributed under the License are 
  11  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS 
  12  * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT 
  13  * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  14  * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the 
  15  * specific language governing rights and limitations under the License. 
  20  * DecodedItem.cpp - class representing the common portions of NSS-style 
  21  * certs and CRLs, with extensions parsed and decoded (still in NSS 
  25 #include "DecodedItem.h" 
  26 #include "cldebugging.h" 
  27 #include "AppleX509CLSession.h" 
  28 #include "CSPAttacher.h" 
  29 #include "CLFieldsCommon.h" 
  30 #include "clNssUtils.h" 
  31 #include <Security/cssmapple.h> 
  34 DecodedItem::DecodedItem( 
  35         AppleX509CLSession      
&session
) 
  39                 mDecodedExtensions(mCoder
, session
) 
  43 DecodedItem::~DecodedItem() 
  49  * Search for DecodedExten by AsnOid or "any unknown extension". 
  50  * Called from getField*() and inferKeyUsage.  
  51  * Returns NULL if specified extension not found. 
  53 const DecodedExten 
*DecodedItem::findDecodedExt( 
  54         const CSSM_OID          
&extnId
,                // for known extensions 
  55         bool                            unknown
,                // otherwise             
  57         uint32                          
&numFields
) const 
  60         const DecodedExten 
*rtnExt 
= NULL
; 
  63         for(dex
=0; dex
<mDecodedExtensions
.numExtensions(); dex
++) { 
  64                 const DecodedExten 
*decodedExt 
= mDecodedExtensions
.getExtension(dex
); 
  66                  * known extensions: OID match AND successful decode (In case 
  67                  *    we encountered a known extension which we couldn't 
  68                  *    decode and fell back to giving the app an unparsed 
  70                  * unknown extensions: just know that we didn't decode it 
  72                 if( ( !unknown 
&& !decodedExt
->berEncoded() && 
  73                       (clCompareCssmData(&decodedExt
->extnId(), &extnId
)) 
  75                     (unknown 
&& decodedExt
->berEncoded()) 
  78                         if(found
++ == index
) { 
  82                         if((rtnExt 
!= NULL
) && (index 
!= 0)) { 
  83                                 /* only determine numFields on search for first one */ 
  89                 /* sucessful return  */