enc = g_crypto_funcs->ccaes_xts_encrypt;
dec = g_crypto_funcs->ccaes_xts_decrypt;
- if (!enc && !dec) {
+ if (!enc || !dec) {
panic("%s: xts mode not registered? enc=%p, dec=%p\n", __FUNCTION__, enc, dec);
}
panic("%s: inconsistent size for AES-XTS context", __FUNCTION__);
}
- enc->init(enc, xts->enc, keylen, key1, key2);
- dec->init(dec, xts->dec, keylen, key1, key2);
+ int rc = enc->init(enc, xts->enc, keylen, key1, key2);
+ rc |= dec->init(dec, xts->dec, keylen, key1, key2);
- return 0; //never fails
+ return rc;
}
int
panic("xts encrypt not a multiple of block size\n");
}
- xtsenc->set_tweak(xts->enc, tweak, iv);
- xtsenc->xts(xts->enc, tweak, ptlen / 16, pt, ct);
+ int rc = xtsenc->set_tweak(xts->enc, tweak, iv);
+ if (rc) {
+ return rc;
+ }
- return 0; //never fails
+ xtsenc->xts(xts->enc, tweak, ptlen / 16, pt, ct);
+ return 0;
}
int
panic("xts decrypt not a multiple of block size\n");
}
- xtsdec->set_tweak(xts->dec, tweak, iv);
- xtsdec->xts(xts->dec, tweak, ptlen / 16, ct, pt);
+ int rc = xtsdec->set_tweak(xts->dec, tweak, iv);
+ if (rc) {
+ return rc;
+ }
- return 0; //never fails
+ xtsdec->xts(xts->dec, tweak, ptlen / 16, ct, pt);
+ return 0;
}
void