if (ret)
return ret;
- ivecd.length = blocksize;
- ivecd.data = ivec;
+ ivecd = make_data(ivec, blocksize);
}
/* size is the length of the input cleartext data. */
- inputd.length = size;
- inputd.data = inptr;
+ inputd = make_data((void *) inptr, size);
/*
* The size of the output buffer isn't part of the old api. Not too
if (ret)
return ret;
- outputd.ciphertext.length = outlen;
- outputd.ciphertext.data = outptr;
+ outputd.ciphertext = make_data(outptr, outlen);
return krb5_c_encrypt(context, eblock->key, 0, ivec ? &ivecd : 0,
&inputd, &outputd);
if (ret)
return ret;
- ivecd.length = blocksize;
- ivecd.data = ivec;
+ ivecd = make_data(ivec, blocksize);
}
/* size is the length of the input ciphertext data */
inputd.enctype = eblock->key->enctype;
- inputd.ciphertext.length = size;
- inputd.ciphertext.data = inptr;
+ inputd.ciphertext = make_data((void *) inptr, size);
/* we don't really know how big this is, but the code tends to assume
that the output buffer size should be the same as the input
buffer size */
- outputd.length = size;
- outputd.data = outptr;
+ outputd = make_data(outptr, size);
return krb5_c_decrypt(context, eblock->key, 0, ivec ? &ivecd : 0,
&inputd, &outputd);
krb5_init_random_key(krb5_context context, const krb5_encrypt_block *eblock,
const krb5_keyblock *keyblock, krb5_pointer *ptr)
{
- krb5_data data;
-
- data.length = keyblock->length;
- data.data = (char *) keyblock->contents;
+ krb5_data data = make_data(keyblock->contents, keyblock->length);
return krb5_c_random_seed(context, &data);
}
krb5_const_pointer seed, size_t seed_length,
krb5_checksum *outcksum)
{
- krb5_data input;
+ krb5_data input = make_data((void *) in, in_length);
krb5_keyblock key;
krb5_error_code ret;
krb5_checksum cksum;
- input.data = in;
- input.length = in_length;
-
key.enctype = ENCTYPE_NULL;
key.length = seed_length;
- key.contents = seed;
+ key.contents = (unsigned char *) seed;
ret = krb5_c_make_checksum(context, ctype, &key, 0, &input, &cksum);
if (ret)
size_t in_length, krb5_const_pointer seed,
size_t seed_length)
{
- krb5_data input;
+ krb5_data input = make_data((void *) in, in_length);
krb5_keyblock key;
krb5_error_code ret;
krb5_boolean valid;
- input.data = in;
- input.length = in_length;
-
key.length = seed_length;
- key.contents = seed;
+ key.contents = (unsigned char *) seed;
ret = krb5_c_verify_checksum(context, &key, 0, &input, cksum, &valid);
if (ret)
krb5_error_code KRB5_CALLCONV
krb5_random_confounder(size_t size, krb5_pointer ptr)
{
- krb5_data random_data;
-
- random_data.length = size;
- random_data.data = ptr;
+ krb5_data random_data = make_data(ptr, size);
return krb5_c_random_make_octets(NULL, &random_data);
}
if (ret)
return ret;
- ivecd.length = blocksize;
- ivecd.data = ivec;
+ ivecd = make_data(ivec, blocksize);
}
enc_data->magic = KV5M_ENC_DATA;
enc_data->kvno = 0;
enc_data->enctype = key->enctype;
- enc_data->ciphertext.length = enclen;
- enc_data->ciphertext.data = malloc(enclen);
- if (enc_data->ciphertext.data == NULL)
- return ENOMEM;
+ ret = alloc_data(&enc_data->ciphertext, enclen);
+ if (ret)
+ return ret;
ret = krb5_c_encrypt(context, key, 0, ivec ? &ivecd : 0, data, enc_data);
if (ret)
if (ret)
return ret;
- ivecd.length = blocksize;
- ivecd.data = ivec;
+ ivecd = make_data(ivec, blocksize);
}
- data->length = enc_data->ciphertext.length;
- data->data = malloc(data->length);
- if (data->data == NULL)
- return ENOMEM;
+ ret = alloc_data(data, enc_data->ciphertext.length);
+ if (ret)
+ return ret;
ret = krb5_c_decrypt(context, key, 0, ivec ? &ivecd : 0, enc_data, data);
if (ret)