summaryrefslogtreecommitdiffstats
path: root/src/crypto/chap.c
diff options
context:
space:
mode:
authorMichael Brown2006-11-21 17:14:17 +0100
committerMichael Brown2006-11-21 17:14:17 +0100
commitd37f82509fcfbbaf56ed267aa4f77a2e66c9ff74 (patch)
tree2623df3577abd34ea7ab896cf2f4f033b2b0a887 /src/crypto/chap.c
parentReduce from 157 to 123 bytes (diff)
downloadipxe-d37f82509fcfbbaf56ed267aa4f77a2e66c9ff74.tar.gz
ipxe-d37f82509fcfbbaf56ed267aa4f77a2e66c9ff74.tar.xz
ipxe-d37f82509fcfbbaf56ed267aa4f77a2e66c9ff74.zip
Added debug statements.
Don't crash when called on an uninitialised chap structure; this allows us to avoid extra checks within iscsi.c to make sure that we receive the CHAP_XXX keys in a sensible order.
Diffstat (limited to 'src/crypto/chap.c')
-rw-r--r--src/crypto/chap.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/crypto/chap.c b/src/crypto/chap.c
index cbfef2d9..6064a30a 100644
--- a/src/crypto/chap.c
+++ b/src/crypto/chap.c
@@ -51,10 +51,15 @@ int chap_init ( struct chap_challenge *chap,
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;
@@ -76,6 +81,9 @@ void chap_update ( struct chap_challenge *chap, const void *data,
assert ( chap->digest != NULL );
assert ( chap->digest_context != NULL );
+ if ( ! chap->digest )
+ return;
+
chap->digest->update ( chap->digest_context, data, len );
}
@@ -92,6 +100,11 @@ void chap_respond ( struct chap_challenge *chap ) {
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 );
}
@@ -103,6 +116,8 @@ void chap_respond ( struct chap_challenge *chap ) {
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 ) );
}