(struct encryption_type): split the blocksize into blocksize and

padsize, padsize is the minimum padding size. they are the same for now
(enctype_*): add padsize
(encrypt_internal): use padsize
(encrypt_internal_derived): use padsize
(wrapped_length): use padsize
(wrapped_length_dervied): use padsize


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11582 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2003-01-15 03:54:51 +00:00
parent e96bdba80d
commit 1f6debd562

View File

@@ -110,6 +110,7 @@ struct encryption_type {
krb5_enctype type;
const char *name;
size_t blocksize;
size_t padsize;
size_t confoundersize;
struct key_type *keytype;
struct checksum_type *checksum;
@@ -1951,6 +1952,7 @@ static struct encryption_type enctype_null = {
ETYPE_NULL,
"null",
1,
1,
0,
&keytype_null,
&checksum_none,
@@ -1963,6 +1965,7 @@ static struct encryption_type enctype_des_cbc_crc = {
"des-cbc-crc",
8,
8,
8,
&keytype_des,
&checksum_crc32,
NULL,
@@ -1974,6 +1977,7 @@ static struct encryption_type enctype_des_cbc_md4 = {
"des-cbc-md4",
8,
8,
8,
&keytype_des,
&checksum_rsa_md4,
&checksum_rsa_md4_des,
@@ -1985,6 +1989,7 @@ static struct encryption_type enctype_des_cbc_md5 = {
"des-cbc-md5",
8,
8,
8,
&keytype_des,
&checksum_rsa_md5,
&checksum_rsa_md5_des,
@@ -1995,6 +2000,7 @@ static struct encryption_type enctype_arcfour_hmac_md5 = {
ETYPE_ARCFOUR_HMAC_MD5,
"arcfour-hmac-md5",
1,
1,
8,
&keytype_arcfour,
&checksum_hmac_md5,
@@ -2007,6 +2013,7 @@ static struct encryption_type enctype_des3_cbc_md5 = {
"des3-cbc-md5",
8,
8,
8,
&keytype_des3,
&checksum_rsa_md5,
&checksum_rsa_md5_des3,
@@ -2018,6 +2025,7 @@ static struct encryption_type enctype_des3_cbc_sha1 = {
"des3-cbc-sha1",
8,
8,
8,
&keytype_des3_derived,
&checksum_sha1,
&checksum_hmac_sha1_des3,
@@ -2029,6 +2037,7 @@ static struct encryption_type enctype_old_des3_cbc_sha1 = {
"old-des3-cbc-sha1",
8,
8,
8,
&keytype_des3,
&checksum_sha1,
&checksum_hmac_sha1_des3,
@@ -2039,6 +2048,7 @@ static struct encryption_type enctype_des_cbc_none = {
ETYPE_DES_CBC_NONE,
"des-cbc-none",
8,
8,
0,
&keytype_des,
&checksum_none,
@@ -2050,6 +2060,7 @@ static struct encryption_type enctype_des_cfb64_none = {
ETYPE_DES_CFB64_NONE,
"des-cfb64-none",
1,
1,
0,
&keytype_des,
&checksum_none,
@@ -2061,6 +2072,7 @@ static struct encryption_type enctype_des_pcbc_none = {
ETYPE_DES_PCBC_NONE,
"des-pcbc-none",
8,
8,
0,
&keytype_des,
&checksum_none,
@@ -2072,6 +2084,7 @@ static struct encryption_type enctype_des3_cbc_none = {
ETYPE_DES3_CBC_NONE,
"des3-cbc-none",
8,
8,
0,
&keytype_des3_derived,
&checksum_none,
@@ -2291,7 +2304,7 @@ encrypt_internal_derived(krb5_context context,
checksum_sz = CHECKSUMSIZE(et->keyed_checksum);
sz = et->confoundersize + len;
block_sz = (sz + et->blocksize - 1) &~ (et->blocksize - 1); /* pad */
block_sz = (sz + et->padsize - 1) &~ (et->padsize - 1); /* pad */
total_sz = block_sz + checksum_sz;
p = calloc(1, total_sz);
if(p == NULL) {
@@ -2359,7 +2372,7 @@ encrypt_internal(krb5_context context,
checksum_sz = CHECKSUMSIZE(et->checksum);
sz = et->confoundersize + checksum_sz + len;
block_sz = (sz + et->blocksize - 1) &~ (et->blocksize - 1); /* pad */
block_sz = (sz + et->padsize - 1) &~ (et->padsize - 1); /* pad */
p = calloc(1, block_sz);
if(p == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
@@ -3118,11 +3131,11 @@ wrapped_length (krb5_context context,
size_t data_len)
{
struct encryption_type *et = crypto->et;
size_t blocksize = et->blocksize;
size_t padsize = et->padsize;
size_t res;
res = et->confoundersize + et->checksum->checksumsize + data_len;
res = (res + blocksize - 1) / blocksize * blocksize;
res = (res + padsize - 1) / padsize * padsize;
return res;
}
@@ -3132,11 +3145,11 @@ wrapped_length_dervied (krb5_context context,
size_t data_len)
{
struct encryption_type *et = crypto->et;
size_t blocksize = et->blocksize;
size_t padsize = et->padsize;
size_t res;
res = et->confoundersize + data_len;
res = (res + blocksize - 1) / blocksize * blocksize;
res = (res + padsize - 1) / padsize * padsize;
res += et->checksum->checksumsize;
return res;
}