krb5: Use iovecs for internal checksum handling
Modify the signature of the checksum operation in the krb5_checksum_type structure so that it processes iovecs rather than solid blocks of data. Update all of the implementations of these functions for all of the checksum types that we support so that they process iovecs, either by iterating through the iovec in each function, or by calling _krb5_evp_digest_iov or _krb5_evp_hmac_iov() Update callers of these functions so that they turn their single blocks of data into a single iovec of the correct type before calling checksum
This commit is contained in:

committed by
Jeffrey Altman

parent
3484f092e5
commit
ca756f0f7f
@@ -99,15 +99,22 @@ static struct _krb5_key_type keytype_des = {
|
||||
static krb5_error_code
|
||||
CRC32_checksum(krb5_context context,
|
||||
struct _krb5_key_data *key,
|
||||
const void *data,
|
||||
size_t len,
|
||||
unsigned usage,
|
||||
const struct krb5_crypto_iov *iov,
|
||||
int niov,
|
||||
Checksum *C)
|
||||
{
|
||||
uint32_t crc;
|
||||
uint32_t crc = 0;
|
||||
unsigned char *r = C->checksum.data;
|
||||
int i;
|
||||
|
||||
_krb5_crc_init_table ();
|
||||
crc = _krb5_crc_update (data, len, 0);
|
||||
|
||||
for (i = 0; i < niov; i++) {
|
||||
if (_krb5_crypto_iov_should_sign(&iov[i]))
|
||||
crc = _krb5_crc_update(iov[i].data.data, iov[i].data.length, crc);
|
||||
}
|
||||
|
||||
r[0] = crc & 0xff;
|
||||
r[1] = (crc >> 8) & 0xff;
|
||||
r[2] = (crc >> 16) & 0xff;
|
||||
@@ -118,12 +125,12 @@ CRC32_checksum(krb5_context context,
|
||||
static krb5_error_code
|
||||
RSA_MD4_checksum(krb5_context context,
|
||||
struct _krb5_key_data *key,
|
||||
const void *data,
|
||||
size_t len,
|
||||
unsigned usage,
|
||||
const struct krb5_crypto_iov *iov,
|
||||
int niov,
|
||||
Checksum *C)
|
||||
{
|
||||
if (EVP_Digest(data, len, C->checksum.data, NULL, EVP_md4(), NULL) != 1)
|
||||
if (_krb5_evp_digest_iov(iov, niov, C->checksum.data, NULL, EVP_md4(), NULL) != 1)
|
||||
krb5_abortx(context, "md4 checksum failed");
|
||||
return 0;
|
||||
}
|
||||
@@ -131,12 +138,12 @@ RSA_MD4_checksum(krb5_context context,
|
||||
static krb5_error_code
|
||||
RSA_MD4_DES_checksum(krb5_context context,
|
||||
struct _krb5_key_data *key,
|
||||
const void *data,
|
||||
size_t len,
|
||||
unsigned usage,
|
||||
const struct krb5_crypto_iov *iov,
|
||||
int niov,
|
||||
Checksum *cksum)
|
||||
{
|
||||
return _krb5_des_checksum(context, EVP_md4(), key, data, len, cksum);
|
||||
return _krb5_des_checksum(context, EVP_md4(), key, iov, niov, cksum);
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
@@ -153,12 +160,12 @@ RSA_MD4_DES_verify(krb5_context context,
|
||||
static krb5_error_code
|
||||
RSA_MD5_DES_checksum(krb5_context context,
|
||||
struct _krb5_key_data *key,
|
||||
const void *data,
|
||||
size_t len,
|
||||
unsigned usage,
|
||||
const struct krb5_crypto_iov *iov,
|
||||
int niov,
|
||||
Checksum *C)
|
||||
{
|
||||
return _krb5_des_checksum(context, EVP_md5(), key, data, len, C);
|
||||
return _krb5_des_checksum(context, EVP_md5(), key, iov, niov, C);
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
|
Reference in New Issue
Block a user