cryptoservices/certificateandkeymgmt/x509/x509cert.cpp
branchRCL_3
changeset 42 eb9b28acd381
parent 33 cf642210ecb7
child 53 b38692a04122
equal deleted inserted replaced
41:9b5a3a9fddf8 42:eb9b28acd381
     1 /*
     1 /*
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  1335 		CleanupStack::PopAndDestroy(subjectKeyIdExt);
  1335 		CleanupStack::PopAndDestroy(subjectKeyIdExt);
  1336 		}
  1336 		}
  1337 		
  1337 		
  1338 	return KeyIdentifierL();
  1338 	return KeyIdentifierL();
  1339 	}
  1339 	}
       
  1340 
       
  1341 EXPORT_C TKeyIdentifier CX509Certificate::SubjectKeyIdL()
       
  1342 	{
       
  1343 	// if it is a v1 or v2 type then there is no way of knowing which is a CA, treat all certs as CA as done in the certificate recognizer.
       
  1344 	if (Version() != 3 )
       
  1345 		{
       
  1346 		return SubjectKeyIdentifierL();
       
  1347 		}
       
  1348 	
       
  1349 	// if it is x509 v3 certificate then check for the basic constraint extension.
       
  1350 	const CX509CertExtension* ext = Extension(KBasicConstraints);
       
  1351 	if (ext)
       
  1352 		{
       
  1353 		CX509BasicConstraintsExt* basic = CX509BasicConstraintsExt::NewLC(ext->Data());
       
  1354 		TBool markedAsCA = basic->IsCA();
       
  1355 		CleanupStack::PopAndDestroy(basic);
       
  1356 		// it can be an intermediate as well as root CA
       
  1357 		if ( markedAsCA )
       
  1358 			{
       
  1359 			return SubjectKeyIdentifierL();
       
  1360 			}
       
  1361 		}
       
  1362 	// For non-CA certs, use the recommended method of computing it from RFC5280, section 4.2.1.2
       
  1363 	return KeyIdentifierL();									
       
  1364 		
       
  1365 	}
       
  1366