cryptomgmtlibs/cryptotokenfw/inc_interfaces/mkeystore_v2.h
changeset 15 da2ae96f639b
parent 8 35751d3474b7
child 45 030c4fbc13d7
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
    35 class TInteger;
    35 class TInteger;
    36 
    36 
    37 class CCTKeyInfo;
    37 class CCTKeyInfo;
    38 struct TCTKeyAttributeFilter;
    38 struct TCTKeyAttributeFilter;
    39 
    39 
       
    40 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
    41 namespace CryptoSpi
       
    42     {
       
    43     class CSigner;
       
    44     class CAsymmetricCipher;
       
    45     class CCryptoParams;
       
    46     }
       
    47 #endif /* SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT */
       
    48 
    40 /**
    49 /**
    41  * A template for signer objects.  It isn't possible to use a base class as the
    50  * A template for signer objects.  It isn't possible to use a base class as the
    42  * signature objects created are not related.
    51  * signature objects created are not related.
    43  *
    52  *
    44  * This template is be instantiated with a CRSASignature* as the
    53  * This template is be instantiated with a CRSASignature* as the
   380 							  TRequestStatus& aStatus) = 0;
   389 							  TRequestStatus& aStatus) = 0;
   381 	
   390 	
   382 	/** Cancels an ongoing ExportPublic() operation */
   391 	/** Cancels an ongoing ExportPublic() operation */
   383 	virtual void CancelExportPublic() = 0;
   392 	virtual void CancelExportPublic() = 0;
   384 
   393 
       
   394 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   395     /**
       
   396      * Opens a key for signing. This function returns a CryptoSPI
       
   397      * signer object. SignL() method should be invoked on this object
       
   398      * to perform the signing operation.
       
   399      *
       
   400      * @param aHandle The handle of the key to be opened.
       
   401      * @param aSigner The returned CryptoSPI signer object.
       
   402      * @param aStatus Returns the status of asynchronous operation, 
       
   403      * possible values of which are given below:-
       
   404      * KErrNone if successful, otherwise a system wide error 
       
   405      * code (in such a case signer object is not allocated). The 
       
   406      * most likely error codes are:-
       
   407      * - KErrNotSupported Default value, used if licensee does not
       
   408      * provide an implementation.
       
   409      * - KErrPermissionDenied If the caller does not conform to
       
   410      * the key use security policy.
       
   411      * - KErrNotFound If the key the handle referes to does not
       
   412      * exist.
       
   413      * - KErrKeyUsage If the key doesn't have sign usage.
       
   414      * - KErrKeyValidity If the key is not currently valid.
       
   415      * - KErrKeySize If the key length is too small.
       
   416      * - KErrKeyAccess If an invalid combination of key access
       
   417      * flags were specified.
       
   418      * 
       
   419      * @capability Requires the caller to have the capabilities
       
   420      * specified in the key use security policy.
       
   421      */
       
   422 	virtual void Open(const TCTTokenObjectHandle& /*aHandle*/,
       
   423 	                  CryptoSpi::CSigner*& /*aSigner*/,
       
   424 	                  TRequestStatus& aStatus)
       
   425 		{
       
   426 		TRequestStatus* status = &aStatus;
       
   427 		User::RequestComplete(status,KErrNotSupported);
       
   428 		}
       
   429 
       
   430     /**
       
   431      * Opens a key for decryption. This function returns a CryptoSPI
       
   432      * signer object. ProcessL() method should be invoked on this object
       
   433      * to perform the decryption operation.
       
   434      *
       
   435      * @param aHandle The handle of the key to be opened.
       
   436      * @param aAsymmetricCipher The returned CryptoSPI cipher object.
       
   437      * @param aStatus Returns the status of asynchronous operation,
       
   438      * possible values of which are given below:-
       
   439      * KErrNone if successful, otherwise a system wide error 
       
   440      * code (in such a case cipher object is not allocated). The 
       
   441      * most likely error codes are:-
       
   442      * - KErrNotSupported Default value, used if licensee does not
       
   443      * provide an implementation.
       
   444      * - KErrPermissionDenied If the caller does not conform to
       
   445      * the key use security policy.
       
   446      * - KErrNotFound If the key the handle referes to does not
       
   447      * exist.
       
   448      * - KErrKeyUsage If the key doesn't have sign usage.
       
   449      * - KErrKeyValidity If the key is not currently valid.
       
   450      * - KErrKeySize If the key length is too small.
       
   451      * - KErrKeyAccess If an invalid combination of key access
       
   452      * flags were specified.
       
   453      *
       
   454      * @capability Requires the caller to have the capabilities
       
   455      * specified in the key use security policy.
       
   456      */
       
   457 	virtual void Open(const TCTTokenObjectHandle& /*aHandle*/,
       
   458 	                  CryptoSpi::CAsymmetricCipher*& /*aAsymmetricCipher*/,
       
   459 	                  TRequestStatus& aStatus)
       
   460 		{
       
   461 		TRequestStatus* status = &aStatus;
       
   462 		User::RequestComplete(status,KErrNotSupported);
       
   463 		}
       
   464 
       
   465 	/**
       
   466 	 * This function takes a token handle and encrypted text as input
       
   467 	 * and stores the decrypted text as one of the output parameters.
       
   468 	 * This API would should be used by the licensees who want to perform
       
   469 	 * decryption operation inside the hardware without using CryptoSPI.
       
   470 	 *
       
   471 	 * @param aHandle The handle of the key to be used for decryption.
       
   472      * @param aCiphertext Contains the encrypted text which has to be
       
   473      * decrypted.
       
   474      * @param aPlaintextPtr This contains the decrypted text. Caller
       
   475      * should take responsibility of this pointer. Derived classes 
       
   476      * should never take ownership of the passed pointer.
       
   477      * @param aStatus Returns the status of asynchronous operation,
       
   478      * possible values are given below:-
       
   479      * KErrNone if successful, otherwise a system wide error 
       
   480      * code (in such a case aPlaintextPtr is not allocated). The 
       
   481      * most likely error codes are:-
       
   482      * - KErrNotSupported Default value, used if licensee does not
       
   483      * provide an implementation.
       
   484      * - KErrPermissionDenied If the caller does not conform to
       
   485      * the key use security policy.
       
   486      * - KErrNotFound If the key the handle referes to does not
       
   487      * exist.
       
   488      * - KErrKeyUsage If the key doesn't have sign usage.
       
   489      * - KErrKeyValidity If the key is not currently valid.
       
   490      * - KErrKeySize If the key length is too small.
       
   491      * - KErrKeyAccess If an invalid combination of key access
       
   492      * flags were specified.
       
   493      * 
       
   494      * @capability Requires the caller to have the capabilities
       
   495      * specified in the key use security policy.
       
   496      */
       
   497 	virtual void Decrypt(const TCTTokenObjectHandle& /*aHandle*/,
       
   498                          const TDesC8& /*aCiphertext*/,
       
   499 	                     HBufC8*& /*aPlaintextPtr*/,
       
   500 	                     TRequestStatus& aStatus)
       
   501 		{
       
   502 		TRequestStatus* status = &aStatus;
       
   503 		User::RequestComplete(status,KErrNotSupported);
       
   504 		}
       
   505 
       
   506 	/**
       
   507 	 * This function takes a token handle and plain text as input and
       
   508 	 * returns the signature as one of the output parameters. This API
       
   509 	 * would enable the licensees to sign a text by just having a handle
       
   510 	 * to key. The key can be stored in the hardware and does not come
       
   511 	 * out at all. This API should be used by the licensees who want to
       
   512 	 * perform signing operation inside the hardware without using
       
   513 	 * CryptoSPI.
       
   514 	 *
       
   515 	 * @param aHandle The handle of the key to be used for decryption.
       
   516 	 * @param aPlainText Text which has to be signed.
       
   517 	 * @param aSignature The cryptoSPI signature. Caller
       
   518 	 * should take responsibility of this pointer. Derived classes 
       
   519      * should never take ownership of the passed pointer.
       
   520 	 * @param aStatus Returns the status of asynchronous operation,
       
   521 	 * possible values are:-
       
   522 	 * KErrNone if successful, otherwise a system wide error 
       
   523      * code (in such a case aSignature is not allocated). The 
       
   524      * most likely error codes are:-
       
   525      * - KErrNotSupported Default value, used if licensee does not
       
   526      * provide an implementation.
       
   527      * - KErrPermissionDenied If the caller does not conform to
       
   528      * the key use security policy.
       
   529      * - KErrNotFound If the key the handle referes to does not
       
   530      * exist.
       
   531      * - KErrKeyUsage If the key doesn't have sign usage.
       
   532      * - KErrKeyValidity If the key is not currently valid.
       
   533      * - KErrKeySize If the key length is too small.
       
   534      * - KErrKeyAccess If an invalid combination of key access
       
   535      * flags were specified.
       
   536      * 
       
   537 	 * @capability Requires the caller to have the capabilities
       
   538 	 * specified in the key use security policy.
       
   539 	 */
       
   540 	virtual void Sign(	const TCTTokenObjectHandle& /*aHandle*/,
       
   541                         const TDesC8& /*aPlainText*/,
       
   542 	                    CryptoSpi::CCryptoParams*& /*aSignature*/,
       
   543 	                    TRequestStatus& aStatus)
       
   544 		{
       
   545 		TRequestStatus* status = &aStatus;
       
   546 		User::RequestComplete(status,KErrNotSupported);
       
   547 		}
       
   548 	
       
   549 #endif /* SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT */
       
   550 
   385 	};
   551 	};
   386 
   552 
   387 
   553 
   388 template <class Signature> inline MCTSigner<Signature>::MCTSigner(MCTToken& aToken)
   554 template <class Signature> inline MCTSigner<Signature>::MCTSigner(MCTToken& aToken)
   389 		: MCTTokenObject(aToken)
   555 		: MCTTokenObject(aToken)