HP-UX C SIP Stack Programmer's Guide (Novembery 2007)

Authentication 189
Client Authentication Implementation
IMPLEMENTING THE MD5 CALLBACK FUNCTION
The input string to the MD5 algorithm is placed on an rpool page. When calling
this callback, the authenticator supplies the RPOOL_Ptr structure which holds
the memory pool, page and offset of the input string.
To implement the MD5 callback function
1. Allocate a consecutive buffer.
2. Use RPOOL_CopyToExternal() to copy the string to the
buffer.
3. Give this buffer as an input to the MD5 algorithm.
4. Use RPOOL_AppendFromExternalToPage to insert the MD5
output into the page that is supplied in the pRpoolMD5Output
parameter.
Sample Code
The following code demonstrates how to implement the MD5 callback function:
/*==========================================================================*/
void RVCALLCONV AuthenticationMD5Ev(
IN RvSipAuthenticatorHandle hAuthenticator,
IN RvSipAppAuthenticatorHandle hAppAuthenticator,
IN RPOOL_Ptr *pRpoolMD5Input,
IN RvUint32 length,
OUT RPOOL_Ptr *pRpoolMD5Output)
{
RvChar *strInput;
RvChar strResponse[33];
RvUint8 digest[20];
MD5_CTX mdc;
/*Allocates the consecutive buffer.*/
strInput = (RvChar*)malloc(length);
/*Gets the string out of the page.*/
RPOOL_CopyToExternal(pRpoolMD5Input->hPool,
pRpoolMD5Input->hPage,
pRpoolMD5Input->offset,
(void*) strInput,
length);