2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Crypto graphy utils api declaration
18 #ifndef C_SEN_CRYPTO_UTILS_H
19 #define C_SEN_CRYPTO_UTILS_H
25 * Set of static convenience methods to help in cryptography
31 * Algorithm taken from of TLS specification RFC 2246 - 5.HMAC and the pseudorandom function
33 * P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +
34 * HMAC_hash(secret, A(2) + seed) +
35 * HMAC_hash(secret, A(3) + seed) + ...
37 * Where + indicates concatenation.
41 * A(i) = HMAC_hash(secret, A(i-1))
43 * P_hash can be iterated as many times as is necessary to produce the
44 * required quantity of data. For example, if P_SHA-1 was being used to
45 * create 64 bytes of data, it would have to be iterated 4 times
46 * (through A(4)), creating 80 bytes of output data; the last 16 bytes
47 * of the final iteration would then be discarded, leaving 64 bytes of
49 * @param aSecret - secret
51 * @param aLength - length of new secret
54 IMPORT_C static HBufC8* GetPSHA1HashL( const TDesC8& aSecret,
59 * Encode data into Base64 format
60 * @param aData - source data
61 * @return encoded data, if some problem occurs, NULL is returned
64 IMPORT_C static HBufC8* EncodeBase64L(const TDesC8& aData);
67 * Decode data from Base64 format
68 * @param aData - source data
69 * @return decoded data, if some problem occurs, NULL is returned
72 IMPORT_C static HBufC8* DecodeBase64L(const TDesC8& aData);
75 * Randomize some data and hash it using MD5 digest algorithm.
76 * @return hashed randomized data (constant length of hash according to MD5 specification)
79 IMPORT_C static HBufC8* RandomAndHashMd5LC();
82 * Create <BinarySecret> tag from security token.
83 * @param aSecret security context token.
84 * @param aValueType Indicates what the security token is
85 * @return <BinarySecret> tag with encoded (base64) token.
87 IMPORT_C static HBufC8* CreateEncodedBinarySecretL( const TDesC8& aSecret,
88 const TDesC8& aValueType );
91 * Timestamp as number of seconds since 1 january 1970
92 * Calculated for present phone time.
93 * @return timestamp value
96 IMPORT_C static HBufC8* GetTimestampL();
100 * Timestamp as number of seconds since 1 january 1970.
101 * Calculated for provided time.
102 * @param aTime base for generated timestamp
103 * @return timestamp value
104 * @since Series60 5.0
106 IMPORT_C static HBufC8* GetTimestampL(TTime aTime);
109 * Randomize some data (based on time) and hash it using MD5 digest algorithm,
110 * convert each byte to hex nember representation
111 * @return hashed randomized data (constant length of hash according to MD5 specification
112 * doubled during hex conversion)
113 * @since Series60 5.0
115 IMPORT_C static HBufC8* GetRandomNonceL();
119 * Hide default C++ constructor.
124 #endif // C_SEN_CRYPTO_UTILS_H