krb5_error_code krb5int_aes_decrypt(krb5_key key, const krb5_data *ivec, krb5_crypto_iov *data, size_t num_data) { int ret = 0; size_t input_length, nblocks; input_length = iov_total_length(data, num_data, FALSE); nblocks = (input_length + BLOCK_SIZE - 1) / BLOCK_SIZE; if (nblocks == 1) { if (input_length != BLOCK_SIZE) return KRB5_BAD_MSIZE; ret = cbc_decr(key, ivec, data, num_data); } else if (nblocks > 1) { ret = cts_decr(key, ivec, data, num_data, input_length); } return ret; }
static krb5_error_code validate(krb5_key key, const krb5_data *ivec, const krb5_crypto_iov *data, size_t num_data, krb5_boolean *empty) { size_t input_length; /* Is our key the correct length? */ if (key->keyblock.length != DES3_KEY_SIZE) return(KRB5_BAD_KEYSIZE); /* Is our input a multiple of the block size, and the IV the correct length? */ input_length = iov_total_length(data, num_data, FALSE); if ((input_length%DES_BLOCK_SIZE) != 0 || (ivec != NULL && ivec->length != DES_BLOCK_SIZE)) return(KRB5_BAD_MSIZE); *empty = (input_length == 0); return 0; }