where does tw routine point to in xts.c?

2010-04-09 Thread Bai Shuwei
Hi, All:
  When i use the cryptsetup command to set the aes-xts-plain
encryption, the system will entry the crypt() routine which defined in
the xts.c file. I find the routine will call two important routines:
tw and fn. I think the fn will point to the aes_encrypt/decrypt
routine. But i want to know which routine the tw will point to for
aes-xts-plain encryption? and where i can find its source code? I put
the segment where the tw routine will be called in the bellow.

   wsrc = w-src.virt.addr;
   wdst = w-dst.virt.addr;

   /* calculate first value of T */
   tw(crypto_cipher_tfm(ctx-tweak), w-iv, w-iv);

   goto first;

   for (;;) {
   do {


Thanks all!

Best Regards

-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


where the tweak routine point to?

2010-04-08 Thread Bai Shuwei
Hi, All:
  When i use the cryptsetup command to set the aes-xts-plain
encryption, the system will entry the crypt() routine which defined in
the xts.c file. I find the routine will call two important routines:
tw and fn. I think the fn will point to the aes_encrypt/decrypt
routine. But i want to know which routine the tw will point to for
aes-xts-plain encryption? and where i can find its source code? I put
the segment where the tw routine will be called in the bellow.

   wsrc = w-src.virt.addr;
   wdst = w-dst.virt.addr;

   /* calculate first value of T */
   tw(crypto_cipher_tfm(ctx-tweak), w-iv, w-iv);

   goto first;

   for (;;) {
   do {


Thanks all!

Best Regards

Bai Shuweiv
-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


device-mapper: remove ioctl failed: device or resource busy

2010-02-05 Thread Bai Shuwei
Hi, All:
   I port the xts-aes algorithm to FPGA board and use it to
encrypt/decrypt the disc.  i will get the bellow information

   But when excute the bellow commands
   cryptsetup luksFormat -c aes-xts-plain -s 256 /dev/loop0
  or
   cryptsetup luksOpen /dev/loop0 test0

   I get the bellow information
   
   device-mapper: remove ioctl failed: device or resource busy
   

   But others are all fine! I can format and mount test0. So i want to
know why the message is printed? Thanks!

Best REgards


Bai Shuwei

-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


device driver for hardware encryption

2010-01-28 Thread Bai Shuwei
Hi, ALl:
   When I add the hardware device driver for crypto, i get the bellow
error information. My kernel is 2.6.26

[  319.938873] BUG: scheduling while atomic: kcryptd/3676/0x0002
[  319.938920] Pid: 3676, comm: kcryptd Tainted: P  2.6.26-2-amd64 #1
[  319.938922]
[  319.938922] Call Trace:
[  319.938926]  [80427cd4] schedule+0x95/0x635
[  319.938934]  [a0eb629b] :libfpga:fpga_dma_open+0xa5/0xab
[  319.938941]  [a0eb67ea] :libfpga:fpga_dma_block_read+0x12b/0x167
[  319.938945]  [802461c5] autoremove_wake_function+0x0/0x2e
[  319.938954]  [a039a248] :dsi_aes:dsi_aes_crypt+0x1db/0x24b
[  319.938960]  [a03a832a] :cbc:crypto_cbc_encrypt+0xe6/0x138
[  319.938964]  [a039e043] :aes_generic:aes_encrypt+0x0/0x21
[  319.938980]  [a0384f6f] :crypto_blkcipher:async_encrypt+0x35/0x3a
[  319.938986]  [a03eea0b] :dm_crypt:crypt_convert+0x1de/0x261
[  319.938995]  [a03eec6e] :dm_crypt:kcryptd_crypt+0x1e0/0x2c5
[  319.939007]  [a03eea8e] :dm_crypt:kcryptd_crypt+0x0/0x2c5
[  319.939012]  [802430c8] run_workqueue+0x82/0x111
[  319.939016]  [80243995] worker_thread+0xd5/0xe0
[  319.939019]  [802461c5] autoremove_wake_function+0x0/0x2e
[  319.939024]  [802438c0] worker_thread+0x0/0xe0
[  319.939026]  [8024609f] kthread+0x47/0x74
[  319.939030]  [8020cf28] child_rip+0xa/0x12
[  319.939041]  [80246058] kthread+0x0/0x74
[  319.939043]  [8020cf1e] child_rip+0x0/0x12

I think it is happed when calling the
wait_event_interruptible(fdev-wait) routine, but i don't know how to
fix it. Hope can get you help. Thanks!

The encryption calling tree and irq handler tree showed in bellow

/* ecryption callint tree */
aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
|--dsi_aes_crypt((unsigned int *)in, (unsigned int *) out);
   |--do_crypt
  |--down_interruptible(fpga-sem)
   fpga_dma_block_write()
   |-- fpga_dma_block_transfer(base, pcie_addr, local_addr,
size, flag | FPGA_DMA_READ_FLAG); /*write data to hardware */
|--wait_event_interruptible(fdev-wait) /* waiting event*/
  up()

/* interrupt calling tree */
pci_fpga_handler(int irq, void *arg)
|--schedule_work(fpga.work);
   |--fpga_work_task(struct work_struct *work)
|-- spin_lock() /*lock*/
   wake_up_interruptible(fpga.wait); /**/
   spin_unlock_irqrestore(fpga.lock, flags);

The fpga.work and fpga.wait define is

init_waitqueue_head(fpga.wait);
INIT_WORK(fpga.work, fpga_work_task);


Best Regards

Bai Shuwei

-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


how the key is generated?

2010-01-26 Thread Bai Shuwei
Hello, everyone:
i add one line in the setkey function which is in xts.c file to
print the in_key value. I find the key value not same i set in the
keyfile by cryptsetup

   my command is
#   cryptsetup luksFormat -d my_keyfile -c xts-aes-plain -s 256 /dev/loop0

# cat my_keyfile
1234567890abcdef1234567890abcdef


I want to know how i set my key to encrypt/decrypt the disc for
xts-aes and aes alogrithm? And how the crypto get the real key to
encrypt the disc or how the key printed in the setkey is genereted and
when? Thanks very much!

Best Regards

Bai Shuwei

-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: how the key is generated?

2010-01-26 Thread Bai Shuwei
On Tue, Jan 26, 2010 at 4:58 PM, Milan Broz mb...@redhat.com wrote:
 On 01/26/2010 09:41 AM, Bai Shuwei wrote:
 Hello, everyone:
     i add one line in the setkey function which is in xts.c file to
 print the in_key value. I find the key value not same i set in the
 keyfile by cryptsetup

    my command is
 #   cryptsetup luksFormat -d my_keyfile -c xts-aes-plain -s 256 /dev/loop0

 -d is key file for key slot (passphrase), volume (master) key for encryption
 is generated using RNG during luksFormat inside cryptsetup.

 You can use pre-generated master key using --master-key-file in cryptsetup 
 1.1.x
 (but note it reads raw input, not hexa encoding). See man page.

 You do not need to modify xts.c btw, try dmsetup table --showkeys for active
 dm-crypt mappings to show used volume key.

 (and also better use dm-cr...@saout.de mailing list for questions related to
 userspace cryptsetup)

 Milan
 --
 mb...@redhat.com


Hi, thanks Milan firstly!
I use dmsetup table --showkeys get the bellow information.

disk$ sudo dmsetup table --showkeys /dev/mapper/dsi0
0 2040 crypt aes-xts-plain
3131313131313131313131313131313131313131313131313131313131313131 0 7:0
2056

If i forget the passphase, can i use the above information/key to
recovery my disk?

Best Regards

Bai Shuwei


-- 
Love other people, as same as love yourself!
Don't think all the time, do it by your hands!

E-Mail: baishu...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html