2 Common operation for Security.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "IpSecCryptIo.h"
18 // Alogrithm's informations for the Encrypt/Decrpt Alogrithm.
20 ENCRYPT_ALGORITHM mIpsecEncryptAlgorithmList
[IPSEC_ENCRYPT_ALGORITHM_LIST_SIZE
] = {
21 {IKE_EALG_NULL
, 0, 0, 1, NULL
, NULL
, NULL
, NULL
},
22 {(UINT8
)-1, 0, 0, 0, NULL
, NULL
, NULL
, NULL
}
25 // Alogrithm's informations for the Authentication algorithm
27 AUTH_ALGORITHM mIpsecAuthAlgorithmList
[IPSEC_AUTH_ALGORITHM_LIST_SIZE
] = {
28 {IKE_AALG_NONE
, 0, 0, 0, NULL
, NULL
, NULL
, NULL
},
29 {IKE_AALG_NULL
, 0, 0, 0, NULL
, NULL
, NULL
, NULL
},
30 {(UINT8
)-1, 0, 0, 0, NULL
, NULL
, NULL
, NULL
}
35 Get the block size of encrypt alogrithm. The block size is based on the algorithm used.
37 @param[in] AlgorithmId The encrypt algorithm ID.
39 @return The value of block size.
43 IpSecGetEncryptBlockSize (
49 for (Index
= 0; Index
< IPSEC_ENCRYPT_ALGORITHM_LIST_SIZE
; Index
++) {
50 if (AlgorithmId
== mIpsecEncryptAlgorithmList
[Index
].AlgorithmId
) {
52 // The BlockSize is same with IvSize.
54 return mIpsecEncryptAlgorithmList
[Index
].BlockSize
;
62 Get the IV size of encrypt alogrithm. The IV size is based on the algorithm used.
64 @param[in] AlgorithmId The encrypt algorithm ID.
66 @return The value of IV size.
70 IpSecGetEncryptIvLength (
76 for (Index
= 0; Index
< IPSEC_ENCRYPT_ALGORITHM_LIST_SIZE
; Index
++) {
77 if (AlgorithmId
== mIpsecEncryptAlgorithmList
[Index
].AlgorithmId
) {
79 // The BlockSize is same with IvSize.
81 return mIpsecEncryptAlgorithmList
[Index
].IvLength
;
89 Get the ICV size of Authenticaion alogrithm. The ICV size is based on the algorithm used.
91 @param[in] AuthAlgorithmId The Authentication algorithm ID.
93 @return The value of ICV size.
98 IN UINT8 AuthAlgorithmId
102 for (Index
= 0; Index
< IPSEC_AUTH_ALGORITHM_LIST_SIZE
; Index
++) {
103 if (AuthAlgorithmId
== mIpsecAuthAlgorithmList
[Index
].AlgorithmId
) {
104 return mIpsecAuthAlgorithmList
[Index
].IcvLength
;
111 Generate a random data for IV. If the IvSize is zero, not needed to create
112 IV and return EFI_SUCCESS.
114 @param[in] IvBuffer The pointer of the IV buffer.
115 @param[in] IvSize The IV size.
117 @retval EFI_SUCCESS Create a random data for IV.
128 //TODO: return CryptGenerateRandom (IvBuffer, IvSize);