diff options
author | Michael Brown <mcb30@etherboot.org> | 2007-01-30 14:55:17 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2007-01-30 14:55:17 +0000 |
commit | db2fde474e4b67482251b3cae5e0068d46af4ab5 (patch) | |
tree | 9e2d2e23241302c1d819b8019c49b311759d85e9 /src/crypto | |
parent | 2f7eac16467abd7f5a354ceea42af8502c0d5f21 (diff) | |
download | ipxe-db2fde474e4b67482251b3cae5e0068d46af4ab5.tar.gz |
Generalise digest_algorithm to crypto_algorithm.
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/chap.c | 14 | ||||
-rw-r--r-- | src/crypto/md5.c | 16 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/crypto/chap.c b/src/crypto/chap.c index 6bebaca5a..2f624564f 100644 --- a/src/crypto/chap.c +++ b/src/crypto/chap.c @@ -42,7 +42,7 @@ * eventually be freed by a call to chap_finish(). */ int chap_init ( struct chap_challenge *chap, - struct digest_algorithm *digest ) { + struct crypto_algorithm *digest ) { size_t state_len; void *state; @@ -52,7 +52,7 @@ int chap_init ( struct chap_challenge *chap, DBG ( "CHAP %p initialising with %s digest\n", chap, digest->name ); - state_len = ( digest->context_len + digest->digest_len ); + state_len = ( digest->ctxsize + digest->digestsize ); state = malloc ( state_len ); if ( ! state ) { DBG ( "CHAP %p could not allocate %d bytes for state\n", @@ -62,9 +62,9 @@ int chap_init ( struct chap_challenge *chap, chap->digest = digest; chap->digest_context = state; - chap->response = ( state + digest->context_len ); - chap->response_len = digest->digest_len; - chap->digest->init ( chap->digest_context ); + chap->response = ( state + digest->ctxsize ); + chap->response_len = digest->digestsize; + digest_init ( chap->digest, chap->digest_context ); return 0; } @@ -83,7 +83,7 @@ void chap_update ( struct chap_challenge *chap, const void *data, if ( ! chap->digest ) return; - chap->digest->update ( chap->digest_context, data, len ); + digest_update ( chap->digest, chap->digest_context, data, len ); } /** @@ -104,7 +104,7 @@ void chap_respond ( struct chap_challenge *chap ) { if ( ! chap->digest ) return; - chap->digest->finish ( chap->digest_context, chap->response ); + digest_final ( chap->digest, chap->digest_context, chap->response ); } /** diff --git a/src/crypto/md5.c b/src/crypto/md5.c index 182b625fe..606423354 100644 --- a/src/crypto/md5.c +++ b/src/crypto/md5.c @@ -177,7 +177,8 @@ static void md5_init(void *context) mctx->byte_count = 0; } -static void md5_update(void *context, const void *data, size_t len) +static void md5_update(void *context, const void *data, void *dst __unused, + size_t len) { struct md5_ctx *mctx = context; const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); @@ -207,7 +208,7 @@ static void md5_update(void *context, const void *data, size_t len) memcpy(mctx->block, data, len); } -static void md5_finish(void *context, void *out) +static void md5_final(void *context, void *out) { struct md5_ctx *mctx = context; const unsigned int offset = mctx->byte_count & 0x3f; @@ -233,11 +234,12 @@ static void md5_finish(void *context, void *out) memset(mctx, 0, sizeof(*mctx)); } -struct digest_algorithm md5_algorithm = { +struct crypto_algorithm md5_algorithm = { .name = "md5", - .context_len = sizeof ( struct md5_ctx ), - .digest_len = MD5_DIGEST_SIZE, + .ctxsize = sizeof ( struct md5_ctx ), + .blocksize = 1, + .digestsize = MD5_DIGEST_SIZE, .init = md5_init, - .update = md5_update, - .finish = md5_finish, + .encode = md5_update, + .final = md5_final, }; |