os/security/crypto/weakcryptospi/inc/cryptostrength.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the 
    16 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file
    23  @publishedPartner
    24  @released
    25 */
    26 
    27 #ifndef __CRYPTOSTRENGTH_H__
    28 #define __CRYPTOSTRENGTH_H__
    29 
    30 /**
    31  * Some builds of the crypto library have restrictions that only allow weak
    32  * ciphers to be used.  This class provides static helper functions for
    33  * determining these restrictions.
    34  */
    35 class TCrypto
    36 	{
    37 public:
    38 	/**
    39 	 * Defines the strength of the cipher. 
    40 	 */
    41 	enum TStrength 
    42 		{ 
    43 		EWeak, EStrong
    44 		};
    45 public:
    46 	/**
    47 	 * Gets the allowed cipher strength.
    48 	 *
    49 	 * @return The allowed cipher strength.	
    50 	 */	
    51 	static IMPORT_C TCrypto::TStrength Strength();
    52 
    53 	/**
    54 	 * Indicates whether a symmetric key is small enough to be allowed. Note
    55 	 * that this function leaves if the key is too large - in other words it can
    56 	 * never return EFalse.
    57 	 * 
    58 	 * @param aSymmetricKeyBits	    The size (in bits) of the symmetric key
    59 	 * @return						Whether the key is small enough to be allowed
    60 	 * 
    61 	 * @leave KErrKeyNotWeakEnough	If the key size is larger than that allowed by the
    62 	 *								cipher strength restrictions of the crypto library.
    63 	 */
    64 	static IMPORT_C TBool IsSymmetricWeakEnoughL(TInt aSymmetricKeyBits);
    65 
    66 	/**
    67 	 * Indicates whether an asymmetric key is small enough to be allowed.  Note
    68 	 * that this function leaves if the key is too large - in other words it can
    69 	 * never return EFalse.
    70 	 *
    71 	 * @param aAsymmetricKeyBits	The size (in bits) of the asymmetric key
    72 	 * @return						Whether the key is small enough to be allowed
    73 	 * 
    74 	 * @leave KErrKeyNotWeakEnough	If the key size is larger than that allowed by the
    75 	 *								cipher strength restrictions of the crypto library.
    76 	 */
    77 	static IMPORT_C TBool IsAsymmetricWeakEnoughL(TInt aAsymmetricKeyBits);
    78 	};
    79 
    80 #endif //__CRYPTOSTRENGTH_H__