xref: /utopia/UTPA2-700.0.x/modules/dscmb/api/nsk2hdi/nsk2hdi_general.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 
2 
3 #include <stdlib.h>
4 #include <string.h>
5 #include "MsCommon.h"
6 
7 #include "nsk_dbg.h"
8 #include "nsk2hdi_header.h"
9 
10 /*****************************************************************************\
11   \Definitions
12 \*****************************************************************************/
13 
14 
15 
16 /*****************************************************************************\
17   \ global variables
18 \*****************************************************************************/
19 
20 
21 /*****************************************************************************\
22   \ NSK2HDI general functions
23 \*****************************************************************************/
NSKHDI_GetHandle(NSK2HDI_HANDLE Handle)24 MS_U32 NSKHDI_GetHandle(NSK2HDI_HANDLE Handle)
25 {
26     MS_U32 u32Handle = 0;
27 
28     if(Handle != NULL)
29     {
30         u32Handle = *(MS_U32*)Handle;
31         //NSK_TRACE(("u32Handle = %lx\n", u32Handle));
32     }
33     else
34     {
35         NSK_TRACE(("Handle = NULL\n"));
36     }
37 
38     return u32Handle;
39 }
40 
41 
NSKHDI_IVDataTrans(MS_U8 NSK2HDI_Algo,MS_U8 * pu8IV1,MS_U8 * pu8IV2,MS_U32 * pu32HWIV)42 MS_U32 NSKHDI_IVDataTrans(MS_U8 NSK2HDI_Algo, MS_U8 *pu8IV1, MS_U8 *pu8IV2, MS_U32 *pu32HWIV)
43 {
44     MS_U32 index;
45 
46     if( (NSK2HDI_SPROFILE_M2M_DES_CBC_SCTE52_IV2 == NSK2HDI_Algo)  ||
47         (NSK2HDI_SPROFILE_M2M_TDES_CBC_SCTE52_IV2 == NSK2HDI_Algo)  ||
48         (NSK2HDI_SPROFILE_SCTE52_DES == NSK2HDI_Algo) )
49     {
50         for(index = 0; index<4 ; index++)
51         {
52             pu32HWIV[index] = ( ((MS_U32)pu8IV1[index*4] << 24 ) +
53                               ((MS_U32)pu8IV1[index*4+1] << 16 ) +
54                               ((MS_U32)pu8IV1[index*4+2] << 8 ) +
55                               ((MS_U32)pu8IV1[index*4+3] )  );
56         }
57 
58         for(index = 0; index<2 ; index++)
59         {
60             pu32HWIV[index+2] = ( ((MS_U32)pu8IV2[index*4] << 24 ) +
61                                 ((MS_U32)pu8IV2[index*4+1] << 16 ) +
62                                 ((MS_U32)pu8IV2[index*4+2] << 8 ) +
63                                 ((MS_U32)pu8IV2[index*4+3] )  );
64         }
65     }
66     else
67     {
68         for(index = 0; index<4 ; index++)
69         {
70             pu32HWIV[index] = ( ((MS_U32)pu8IV1[index*4] << 24 ) +
71                               ((MS_U32)pu8IV1[index*4+1] << 16 ) +
72                               ((MS_U32)pu8IV1[index*4+2] << 8 ) +
73                               ((MS_U32)pu8IV1[index*4+3] )  );
74         }
75     }
76     return TRUE;
77 }
78 
79 
80