/* To handle all non-aligned bytes (not aligned to 16B size) */
if (byte_cnt) {
- aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0));
- aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1));
- aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2));
- aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */
+ u8 temparea[16] = {0,};
+
+ memcpy(temparea, ((u32 *) in_arg + (i * 4)), byte_cnt);
+
+ aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 0));
+ aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 1));
+ aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 2));
+ aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 3)); /* start crypto */
while (aes->controlr.BUS) {
}
- *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R;
- *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R;
- *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R;
- *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R;
-
- /* to ensure that the extended pages are clean */
- memset (out_arg + (i * 16) + (nbytes % AES_BLOCK_SIZE), 0,
- (AES_BLOCK_SIZE - (nbytes % AES_BLOCK_SIZE)));
+ *((volatile u32 *) temparea + 0) = aes->OD3R;
+ *((volatile u32 *) temparea + 1) = aes->OD2R;
+ *((volatile u32 *) temparea + 2) = aes->OD1R;
+ *((volatile u32 *) temparea + 3) = aes->OD0R;
+ memcpy(((u32 *) out_arg + (i * 4)), temparea, byte_cnt);
}
//tc.chen : copy iv_arg back
struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
int err;
- unsigned int enc_bytes;
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
- while ((nbytes = enc_bytes = walk.nbytes)) {
- u8 *iv = walk.iv;
- enc_bytes -= (nbytes % AES_BLOCK_SIZE);
- ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0);
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
+ while ((nbytes = walk.nbytes)) {
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ walk.iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ err = blkcipher_walk_done(desc, &walk, 0);
}
-
return err;
}
struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
int err;
- unsigned int dec_bytes;
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
- while ((nbytes = dec_bytes = walk.nbytes)) {
- u8 *iv = walk.iv;
- dec_bytes -= (nbytes % AES_BLOCK_SIZE);
- ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0);
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
+ while ((nbytes = walk.nbytes)) {
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ walk.iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ err = blkcipher_walk_done(desc, &walk, 0);
}
return err;
.cra_driver_name = "ifxdeu-ctr(aes)",
.cra_priority = 400,
.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
- .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_blocksize = 1,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_blkcipher_type,
.cra_module = THIS_MODULE,
.cra_driver_name = "ifxdeu-ctr-rfc3686(aes)",
.cra_priority = 400,
.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
- .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_blocksize = 1,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_blkcipher_type,
.cra_module = THIS_MODULE,
{
int ret = -ENOSYS;
-
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
- if (!disable_multiblock) {
- ifxdeu_aes_alg.cra_u.cipher.cia_max_nbytes = AES_BLOCK_SIZE; //(size_t)-1;
- ifxdeu_aes_alg.cra_u.cipher.cia_req_align = 16;
- ifxdeu_aes_alg.cra_u.cipher.cia_ecb = ifx_deu_aes_ecb;
- ifxdeu_aes_alg.cra_u.cipher.cia_cbc = ifx_deu_aes_cbc;
- ifxdeu_aes_alg.cra_u.cipher.cia_cfb = ifx_deu_aes_cfb;
- ifxdeu_aes_alg.cra_u.cipher.cia_ofb = ifx_deu_aes_ofb;
- }
-#endif
+ aes_chip_init();
if ((ret = crypto_register_alg(&ifxdeu_aes_alg)))
goto aes_err;
if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg)))
goto ctr_rfc3686_aes_err;
- aes_chip_init ();
-
CRTCL_SECT_INIT;