diff options
author | Luke Howard <lukeh@padl.com> | 2008-11-15 23:59:20 +0000 |
---|---|---|
committer | Luke Howard <lukeh@padl.com> | 2008-11-15 23:59:20 +0000 |
commit | f212de1f1de127652266e3785b6a79338a13b6d0 (patch) | |
tree | d0c8e840fd3a142bc07747ab9c02957413920fb9 | |
parent | 4ab983cd1720e1d3011e8f20fa15d7fb03b6b333 (diff) | |
download | krb5-f212de1f1de127652266e3785b6a79338a13b6d0.zip krb5-f212de1f1de127652266e3785b6a79338a13b6d0.tar.gz krb5-f212de1f1de127652266e3785b6a79338a13b6d0.tar.bz2 |
Use return value of get/put block to indicate termination condition
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/mskrb-integ@21118 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/lib/crypto/aead.c | 8 | ||||
-rw-r--r-- | src/lib/crypto/aead.h | 4 | ||||
-rw-r--r-- | src/lib/crypto/crypto_length.c | 2 | ||||
-rw-r--r-- | src/lib/crypto/decrypt_iov.c | 1 | ||||
-rw-r--r-- | src/lib/crypto/des/d3_aead.c | 8 | ||||
-rw-r--r-- | src/lib/crypto/enc_provider/aes_ctr.c | 8 | ||||
-rw-r--r-- | src/lib/crypto/keyhash_provider/aescbc.c | 4 |
7 files changed, 15 insertions, 20 deletions
diff --git a/src/lib/crypto/aead.c b/src/lib/crypto/aead.c index 9b2e564..089aab9 100644 --- a/src/lib/crypto/aead.c +++ b/src/lib/crypto/aead.c @@ -243,7 +243,7 @@ pad_to_boundary_p(const krb5_crypto_iov *data, return 1; } -void KRB5_CALLCONV +krb5_boolean KRB5_CALLCONV krb5int_c_iov_get_block(unsigned char *block, size_t block_size, const krb5_crypto_iov *data, @@ -292,9 +292,11 @@ krb5int_c_iov_get_block(unsigned char *block, if (iov_state->iov_pos < num_data) dump_block("get_block", i, j, block, block_size); #endif + + return (iov_state->iov_pos < num_data); } -void KRB5_CALLCONV +krb5_boolean KRB5_CALLCONV krb5int_c_iov_put_block(const krb5_crypto_iov *data, size_t num_data, unsigned char *block, @@ -340,6 +342,8 @@ krb5int_c_iov_put_block(const krb5_crypto_iov *data, if (iov_state->iov_pos < num_data) dump_block("put_block", i, j, block, block_size); #endif + + return (iov_state->iov_pos < num_data); } krb5_error_code KRB5_CALLCONV diff --git a/src/lib/crypto/aead.h b/src/lib/crypto/aead.h index 0876b16..f183d1a 100644 --- a/src/lib/crypto/aead.h +++ b/src/lib/crypto/aead.h @@ -68,14 +68,14 @@ struct iov_block_state { (_state)->include_sign_only = \ (_state)->pad_to_boundary = 0) -void KRB5_CALLCONV +krb5_boolean KRB5_CALLCONV krb5int_c_iov_get_block(unsigned char *block, size_t block_size, const krb5_crypto_iov *data, size_t num_data, struct iov_block_state *iov_state); -void KRB5_CALLCONV +krb5_boolean KRB5_CALLCONV krb5int_c_iov_put_block(const krb5_crypto_iov *data, size_t num_data, unsigned char *block, diff --git a/src/lib/crypto/crypto_length.c b/src/lib/crypto/crypto_length.c index 9a15f00..ab6e6e1 100644 --- a/src/lib/crypto/crypto_length.c +++ b/src/lib/crypto/crypto_length.c @@ -1,5 +1,5 @@ /* - * lib/crypto/encrypt_iov.c + * lib/crypto/crypto_length.c * * Copyright 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. diff --git a/src/lib/crypto/decrypt_iov.c b/src/lib/crypto/decrypt_iov.c index 5563efb..1a98b06 100644 --- a/src/lib/crypto/decrypt_iov.c +++ b/src/lib/crypto/decrypt_iov.c @@ -26,6 +26,7 @@ #include "k5-int.h" #include "etypes.h" +#include "aead.h" krb5_error_code KRB5_CALLCONV krb5_c_decrypt_iov(krb5_context context, diff --git a/src/lib/crypto/des/d3_aead.c b/src/lib/crypto/des/d3_aead.c index 9605bac..8463fc8 100644 --- a/src/lib/crypto/des/d3_aead.c +++ b/src/lib/crypto/des/d3_aead.c @@ -72,9 +72,7 @@ krb5int_des3_cbc_encrypt_iov(krb5_crypto_iov *data, ip = iblock; op = oblock; - krb5int_c_iov_get_block(iblock, MIT_DES_BLOCK_LENGTH, data, num_data, &input_pos); - - if (input_pos.iov_pos == num_data) + if (!krb5int_c_iov_get_block(iblock, MIT_DES_BLOCK_LENGTH, data, num_data, &input_pos)) break; GET_HALF_BLOCK(temp, ip); @@ -158,9 +156,7 @@ krb5int_des3_cbc_decrypt_iov(krb5_crypto_iov *data, * right. Save this cipher block for later. */ - krb5int_c_iov_get_block(iblock, MIT_DES_BLOCK_LENGTH, data, num_data, &input_pos); - - if (input_pos.iov_pos == num_data) + if (!krb5int_c_iov_get_block(iblock, MIT_DES_BLOCK_LENGTH, data, num_data, &input_pos)) break; ip = iblock; diff --git a/src/lib/crypto/enc_provider/aes_ctr.c b/src/lib/crypto/enc_provider/aes_ctr.c index 0759049..9fa18a3 100644 --- a/src/lib/crypto/enc_provider/aes_ctr.c +++ b/src/lib/crypto/enc_provider/aes_ctr.c @@ -72,9 +72,7 @@ krb5int_aes_encrypt_ctr_iov(const krb5_keyblock *key, unsigned char plain[BLOCK_SIZE]; unsigned char ectr[BLOCK_SIZE]; - krb5int_c_iov_get_block((unsigned char *)plain, BLOCK_SIZE, data, num_data, &input_pos); - - if (input_pos.iov_pos == num_data) + if (!krb5int_c_iov_get_block((unsigned char *)plain, BLOCK_SIZE, data, num_data, &input_pos)) break; if (aes_enc_blk(ctr, ectr, &ctx) != aes_good) @@ -132,9 +130,7 @@ krb5int_aes_decrypt_ctr_iov(const krb5_keyblock *key, unsigned char ectr[BLOCK_SIZE]; unsigned char cipher[BLOCK_SIZE]; - krb5int_c_iov_get_block((unsigned char *)cipher, BLOCK_SIZE, data, num_data, &input_pos); - - if (input_pos.iov_pos == num_data) + if (!krb5int_c_iov_get_block((unsigned char *)cipher, BLOCK_SIZE, data, num_data, &input_pos)) break; if (aes_enc_blk(ctr, ectr, &ctx) != aes_good) diff --git a/src/lib/crypto/keyhash_provider/aescbc.c b/src/lib/crypto/keyhash_provider/aescbc.c index 06e9346..70c5060 100644 --- a/src/lib/crypto/keyhash_provider/aescbc.c +++ b/src/lib/crypto/keyhash_provider/aescbc.c @@ -72,9 +72,7 @@ k5_aescbc_hash_iov (const krb5_keyblock *key, krb5_keyusage usage, for (;;) { unsigned char blockB[BLOCK_SIZE]; - krb5int_c_iov_get_block(blockB, BLOCK_SIZE, data, num_data, &iov_state); - - if (iov_state.iov_pos == num_data) + if (!krb5int_c_iov_get_block(blockB, BLOCK_SIZE, data, num_data, &iov_state)) break; xorblock(blockB, blockY); |