equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2004 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2000, 2004, 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 "Eclipse Public License v1.0" |
5 * under the terms of "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". |
39 // ~CCrCrypto |
39 // ~CCrCrypto |
40 // Destructor. |
40 // Destructor. |
41 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
42 CCrCrypto::~CCrCrypto() |
42 CCrCrypto::~CCrCrypto() |
43 { |
43 { |
44 Reset(); |
|
45 |
|
46 if( iAlgorithmInfos ) |
44 if( iAlgorithmInfos ) |
47 { |
45 { |
|
46 Reset(); |
|
47 |
48 iAlgorithmInfos->Reset(); |
48 iAlgorithmInfos->Reset(); |
49 delete iAlgorithmInfos; |
49 delete iAlgorithmInfos; |
50 iAlgorithmInfos = NULL; |
50 iAlgorithmInfos = NULL; |
51 } |
51 } |
52 } |
52 } |
711 TDes8& aTrg) // Output data, possible keys and IV |
711 TDes8& aTrg) // Output data, possible keys and IV |
712 { |
712 { |
713 TInt remainder = 0; |
713 TInt remainder = 0; |
714 TInt rounds = 0; |
714 TInt rounds = 0; |
715 TInt pushedToCStack = 0; |
715 TInt pushedToCStack = 0; |
716 TInt inputSize = MesDigestInputSize(aHashFunc); |
716 TInt inputSize = MesDigestInputSizeL(aHashFunc); |
717 TInt outputSize = MesDigestOutputSize(aHashFunc); |
717 TInt outputSize = MesDigestOutputSizeL(aHashFunc); |
718 |
718 |
719 // Step 1: Construct D by concatenating copies of ID. |
719 // Step 1: Construct D by concatenating copies of ID. |
720 // Construct a string D |
720 // Construct a string D |
721 HBufC8* D_buf = HBufC8::NewLC(inputSize); |
721 HBufC8* D_buf = HBufC8::NewLC(inputSize); |
722 ++pushedToCStack; |
722 ++pushedToCStack; |
863 |
863 |
864 return status; |
864 return status; |
865 } |
865 } |
866 |
866 |
867 // ----------------------------------------------------------------------------- |
867 // ----------------------------------------------------------------------------- |
868 // CCrCrypto::MesDigestInputSize |
868 // CCrCrypto::MesDigestInputSizeL |
869 // Returns input size of the message digest algorithm. |
869 // Returns input size of the message digest algorithm. |
870 // Return Values: Input size of the message digest algorithm in bytes. |
870 // Return Values: Input size of the message digest algorithm in bytes. |
871 // If unknown algorithm returns -1. |
871 // If unknown algorithm, leaves with KErrNotSupported. |
872 // ----------------------------------------------------------------------------- |
872 // ----------------------------------------------------------------------------- |
873 TInt CCrCrypto::MesDigestInputSize(TCrAlgorithm aDigestAlg) |
873 TInt CCrCrypto::MesDigestInputSizeL( TCrAlgorithm aDigestAlg ) |
874 { |
874 { |
875 switch(aDigestAlg) |
875 switch(aDigestAlg) |
876 { |
876 { |
877 case ECrSHA1: |
877 case ECrSHA1: |
878 case ECrMD5: |
878 case ECrMD5: |
880 { |
880 { |
881 return KDigestInputSize; |
881 return KDigestInputSize; |
882 } |
882 } |
883 default: |
883 default: |
884 { |
884 { |
885 return -1; |
885 User::Leave( KErrNotSupported ); |
886 } |
886 return -1; // keeps compiler happy |
887 } |
887 } |
888 } |
888 } |
889 |
889 } |
890 // ----------------------------------------------------------------------------- |
890 |
891 // CCrCrypto::MesDigestOutputSize |
891 // ----------------------------------------------------------------------------- |
|
892 // CCrCrypto::MesDigestOutputSizeL |
892 // Returns output size of the message digest algorithm. |
893 // Returns output size of the message digest algorithm. |
893 // Parameters: aDigestAlg message digest algortihm |
894 // Parameters: aDigestAlg message digest algortihm |
894 // Return Values: Output size of the message digest algorithm in bytes. |
895 // Return Values: Output size of the message digest algorithm in bytes. |
895 // If unknown algorithm returns -1. |
896 // If unknown algorithm, leaves with KErrNotSupported. |
896 // ----------------------------------------------------------------------------- |
897 // ----------------------------------------------------------------------------- |
897 TInt CCrCrypto::MesDigestOutputSize(TCrAlgorithm aDigestAlg) |
898 TInt CCrCrypto::MesDigestOutputSizeL( TCrAlgorithm aDigestAlg ) |
898 { |
899 { |
899 switch(aDigestAlg) |
900 switch(aDigestAlg) |
900 { |
901 { |
901 case ECrSHA1: |
902 case ECrSHA1: |
902 { |
903 { |
907 { |
908 { |
908 return KCrMediumDigestLength; |
909 return KCrMediumDigestLength; |
909 } |
910 } |
910 default: |
911 default: |
911 { |
912 { |
912 return -1; |
913 User::Leave( KErrNotSupported ); |
|
914 return -1; // keeps compiler happy |
913 } |
915 } |
914 } |
916 } |
915 } |
917 } |
916 |
918 |
917 // End Of Line |
919 // End Of Line |