56
57
static krb5_error_code
58
validate_and_schedule_iov(const krb5_keyblock *key, const krb5_data *ivec,
59
const krb5_crypto_iov *data, size_t num_data,
60
mit_des3_key_schedule *schedule)
62
size_t i, input_length;
64
for (i = 0, input_length = 0; i < num_data; i++) {
65
const krb5_crypto_iov *iov = &data[i];
68
input_length += iov->data.length;
71
if (key->length != 24)
72
return(KRB5_BAD_KEYSIZE);
73
if ((input_length%8) != 0)
74
return(KRB5_BAD_MSIZE);
75
if (ivec && (ivec->length != 8))
76
return(KRB5_BAD_MSIZE);
78
switch (mit_des3_key_sched(*(mit_des3_cblock *)key->contents,
81
return(KRB5DES_BAD_KEYPAR);
83
return(KRB5DES_WEAK_KEY);
88
static krb5_error_code
57
89
k5_des3_encrypt(const krb5_keyblock *key, const krb5_data *ivec,
58
90
const krb5_data *input, krb5_data *output)
68
100
krb5int_des3_cbc_encrypt((krb5_pointer) input->data,
69
101
(krb5_pointer) output->data, input->length,
70
102
schedule[0], schedule[1], schedule[2],
71
ivec?(unsigned char *) ivec->data:(unsigned char *)mit_des_zeroblock);
103
ivec?(const unsigned char *) ivec->data:(const unsigned char *)mit_des_zeroblock);
73
105
zap(schedule, sizeof(schedule));
90
122
krb5int_des3_cbc_decrypt((krb5_pointer) input->data,
91
123
(krb5_pointer) output->data, input->length,
92
124
schedule[0], schedule[1], schedule[2],
93
ivec?(unsigned char *) ivec->data:(unsigned char *)mit_des_zeroblock);
125
ivec?(const unsigned char *) ivec->data:(const unsigned char *)mit_des_zeroblock);
95
127
zap(schedule, sizeof(schedule));
164
static krb5_error_code
165
k5_des3_encrypt_iov(const krb5_keyblock *key,
166
const krb5_data *ivec,
167
krb5_crypto_iov *data,
170
mit_des3_key_schedule schedule;
173
err = validate_and_schedule_iov(key, ivec, data, num_data, &schedule);
177
/* this has a return value, but the code always returns zero */
178
krb5int_des3_cbc_encrypt_iov(data, num_data,
179
schedule[0], schedule[1], schedule[2],
180
ivec != NULL ? (const unsigned char *) ivec->data : NULL);
182
zap(schedule, sizeof(schedule));
187
static krb5_error_code
188
k5_des3_decrypt_iov(const krb5_keyblock *key,
189
const krb5_data *ivec,
190
krb5_crypto_iov *data,
193
mit_des3_key_schedule schedule;
196
err = validate_and_schedule_iov(key, ivec, data, num_data, &schedule);
200
/* this has a return value, but the code always returns zero */
201
krb5int_des3_cbc_decrypt_iov(data, num_data,
202
schedule[0], schedule[1], schedule[2],
203
ivec != NULL ? (const unsigned char *) ivec->data : NULL);
205
zap(schedule, sizeof(schedule));
132
210
const struct krb5_enc_provider krb5int_enc_des3 = {