@@ -65,7 +65,6 @@ written by
6565#define HCRYPT_MSG_SRT_OFS_MSGNO 4
6666#define HCRYPT_MSG_SRT_SHF_KFLGS 27 //shift
6767
68- static hcrypt_MsgInfo _hcMsg_SRT_MsgInfo ;
6968
7069static unsigned hcryptMsg_SRT_GetKeyFlags (unsigned char * msg )
7170{
@@ -110,7 +109,22 @@ static void hcryptMsg_SRT_IndexMsg(unsigned char *msg, unsigned char *pfx_cache)
110109 return ; //nothing to do, header and index maintained by SRT
111110}
112111
113- static int hcryptMsg_SRT_ParseMsg (unsigned char * msg )
112+ static const hcrypt_MsgInfo _hcMsg_SRT_MsgInfo = {
113+ .hdr_len = HCRYPT_MSG_SRT_HDR_SZ ,
114+ .pfx_len = HCRYPT_MSG_SRT_PFX_SZ ,
115+ .getKeyFlags = hcryptMsg_SRT_GetKeyFlags ,
116+ .getPki = hcryptMsg_SRT_GetPki ,
117+ .setPki = hcryptMsg_SRT_SetPki ,
118+ .resetCache = hcryptMsg_SRT_ResetCache ,
119+ .indexMsg = hcryptMsg_SRT_IndexMsg
120+ };
121+
122+ const hcrypt_MsgInfo * hcryptMsg_SRT_MsgInfo (void )
123+ {
124+ return (& _hcMsg_SRT_MsgInfo );
125+ }
126+
127+ int hcryptMsg_SRT_ParseMsg (const hcrypt_MsgInfo * mi , unsigned char * msg )
114128{
115129 int rc ;
116130
@@ -126,10 +140,10 @@ static int hcryptMsg_SRT_ParseMsg(unsigned char *msg)
126140
127141 switch (rc ) {
128142 case HCRYPT_MSG_PT_MS :
129- if (hcryptMsg_HasNoSek (& _hcMsg_SRT_MsgInfo , msg )
130- || hcryptMsg_HasBothSek (& _hcMsg_SRT_MsgInfo , msg )) {
143+ if (hcryptMsg_HasNoSek (mi , msg )
144+ || hcryptMsg_HasBothSek (mi , msg )) {
131145 HCRYPT_LOG (LOG_ERR , "invalid MS msg flgs: %02x\n" ,
132- hcryptMsg_GetKeyIndex (& _hcMsg_SRT_MsgInfo , msg ));
146+ hcryptMsg_GetKeyIndex (mi , msg ));
133147 return (-1 );
134148 }
135149 break ;
@@ -153,19 +167,4 @@ static int hcryptMsg_SRT_ParseMsg(unsigned char *msg)
153167 return (rc ); /* -1: error, 0: unknown: >0: PT */
154168}
155169
156- static hcrypt_MsgInfo _hcMsg_SRT_MsgInfo ;
157-
158- hcrypt_MsgInfo * hcryptMsg_SRT_MsgInfo (void )
159- {
160- _hcMsg_SRT_MsgInfo .hdr_len = HCRYPT_MSG_SRT_HDR_SZ ;
161- _hcMsg_SRT_MsgInfo .pfx_len = HCRYPT_MSG_SRT_PFX_SZ ;
162- _hcMsg_SRT_MsgInfo .getKeyFlags = hcryptMsg_SRT_GetKeyFlags ;
163- _hcMsg_SRT_MsgInfo .getPki = hcryptMsg_SRT_GetPki ;
164- _hcMsg_SRT_MsgInfo .setPki = hcryptMsg_SRT_SetPki ;
165- _hcMsg_SRT_MsgInfo .resetCache = hcryptMsg_SRT_ResetCache ;
166- _hcMsg_SRT_MsgInfo .indexMsg = hcryptMsg_SRT_IndexMsg ;
167- _hcMsg_SRT_MsgInfo .parseMsg = hcryptMsg_SRT_ParseMsg ;
168-
169- return (& _hcMsg_SRT_MsgInfo );
170- }
171170
0 commit comments