cryptoservices/certificateandkeymgmt/crypto/Signed.cpp
changeset 19 cd501b96611d
parent 8 35751d3474b7
equal deleted inserted replaced
15:da2ae96f639b 19:cd501b96611d
   451 	case ESHA1:
   451 	case ESHA1:
   452 		{
   452 		{
   453 		digest = CSHA1::NewL();
   453 		digest = CSHA1::NewL();
   454 		break;
   454 		break;
   455 		}
   455 		}
       
   456 	case ESHA224:
       
   457 	    {
       
   458 	    digest = CSHA2::NewL(E224Bit);
       
   459 	    break;
       
   460 	    }
       
   461 	case ESHA256:
       
   462 	    {
       
   463 	    digest = CSHA2::NewL(E256Bit);
       
   464 	    break;
       
   465 	    }
       
   466 	case ESHA384:
       
   467 	    {
       
   468 	    digest = CSHA2::NewL(E384Bit);
       
   469 	    break;
       
   470 	    }
       
   471 	case ESHA512:
       
   472 	    {
       
   473 	    digest = CSHA2::NewL(E512Bit);
       
   474 	    break;
       
   475 	    }
       
   476 
   456 	default:
   477 	default:
   457 		User::Leave(KErrArgument);
   478 		User::Leave(KErrArgument);
   458 		}
   479 		}
   459 
   480 
   460 	//Hash the data	
   481 	//Hash the data	
   506 EXPORT_C void CSignedObject::ExternalizeL(RWriteStream& aStream) const 
   527 EXPORT_C void CSignedObject::ExternalizeL(RWriteStream& aStream) const 
   507 	{
   528 	{
   508 	aStream.WriteInt32L(iEncoding->Length());
   529 	aStream.WriteInt32L(iEncoding->Length());
   509 	aStream.WriteL(*iEncoding);
   530 	aStream.WriteL(*iEncoding);
   510 	}
   531 	}
   511 /*
   532 
   512 EXPORT_C void CSignedObject::ConstructL(RReadStream& aStream, TSignedObjectParser* aParser, TKeyFactory* aFactory)
   533 
   513 	{
       
   514 	if (iParser != NULL)
       
   515 		{
       
   516 		delete iParser;
       
   517 		iParser = NULL;
       
   518 		}
       
   519 	iParser = aParser;
       
   520 	if (iKeyFactory != NULL)
       
   521 		{
       
   522 		delete iKeyFactory;
       
   523 		iKeyFactory = NULL;
       
   524 		}
       
   525 	iKeyFactory = aFactory;
       
   526 	if (iEncoding != NULL)
       
   527 		{
       
   528 		User::Leave(KErrGeneral);
       
   529 		}
       
   530 	TInt len = aStream.ReadInt32L();
       
   531 	iEncoding = HBufC8::NewL(aStream,len);
       
   532 	DoConstructL();
       
   533 	}
       
   534 
       
   535 EXPORT_C void CSignedObject::ConstructL(const TPtrC8& aBinaryData, TSignedObjectParser* aParser, TKeyFactory* aFactory)
       
   536 	{
       
   537 	iParser = aParser;
       
   538 	iKeyFactory = aFactory;
       
   539 	//take a copy of the whole thing
       
   540 	iEncoding = aBinaryData.AllocL();
       
   541 	DoConstructL();
       
   542 	}
       
   543 
       
   544 EXPORT_C void CSignedObject::ConstructL(const CSignedObject& aSignedObject, TSignedObjectParser* aParser, TKeyFactory* aFactory)
       
   545 	{
       
   546 	iParser = aParser;
       
   547 	iKeyFactory = aFactory;
       
   548 	iEncoding = aSignedObject.iEncoding->AllocL();
       
   549 	iFingerprint = aSignedObject.iFingerprint->AllocL();
       
   550 	iSignature = aSignedObject.iSignature->AllocL();
       
   551 	iSigningAlgorithm = CSigningAlgorithmIdentifier::NewL(*(aSignedObject.iSigningAlgorithm));
       
   552 	}
       
   553 
       
   554 void CSignedObject::DoConstructL()
       
   555 	{
       
   556 	//generate your fingerprint
       
   557 	CMD5* hash = CMD5::NewL();
       
   558 	CleanupStack::PushL(hash);
       
   559 	iFingerprint = hash->Hash(Encoding()).AllocL();
       
   560 	CleanupStack::PopAndDestroy();
       
   561 	//ask the parser for the signature
       
   562 	iSignature = iParser->SignatureL(Encoding());
       
   563 	//ask the parser for the algorithm ID
       
   564 	iSigningAlgorithm = iParser->AlgorithmIdL(Encoding());
       
   565 	}
       
   566 */
       
   567 //****************************************************************************************//
   534 //****************************************************************************************//
   568 //certificate base
   535 //certificate base
   569 EXPORT_C CCertificate::~CCertificate()
   536 EXPORT_C CCertificate::~CCertificate()
   570 	{
   537 	{
   571 	delete iSerialNumber;
   538 	delete iSerialNumber;