assert ( chap->digest_context == NULL );
assert ( chap->response == NULL );
+ DBG ( "CHAP %p initialising with %s digest\n", chap, digest->name );
+
state_len = ( digest->context_len + digest->digest_len );
state = malloc ( state_len );
- if ( ! state )
+ if ( ! state ) {
+ DBG ( "CHAP %p could not allocate %d bytes for state\n",
+ chap, state_len );
return -ENOMEM;
+ }
chap->digest = digest;
chap->digest_context = state;
assert ( chap->digest != NULL );
assert ( chap->digest_context != NULL );
+ if ( ! chap->digest )
+ return;
+
chap->digest->update ( chap->digest_context, data, len );
}
assert ( chap->digest_context != NULL );
assert ( chap->response != NULL );
+ DBG ( "CHAP %p responding to challenge\n", chap );
+
+ if ( ! chap->digest )
+ return;
+
chap->digest->finish ( chap->digest_context, chap->response );
}
void chap_finish ( struct chap_challenge *chap ) {
void *state = chap->digest_context;
+ DBG ( "CHAP %p finished\n", chap );
+
free ( state );
memset ( chap, 0, sizeof ( *chap ) );
}