<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic caam-keygen: using black key from a plaintext in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1640354#M204848</link>
    <description>&lt;P&gt;caam-keygen supports generating a black key from plaintext. Is it possible to:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. decrypting data from one device on another if the keys were generated with the same plaintext? (OTPMKs are different)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2. using this plaintext as a key for dmsetup and preparing an image, for example, on a host machine, and later mounting the image on a device using a black key generated with the same plaintext?&lt;/P&gt;&lt;P&gt;In other words, is plaintext interpreted as a symmetric key and used for encryption/decryption? Or is it just some modifier that allows generating black keys similarly on the same/different devices?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Apr 2023 08:07:49 GMT</pubDate>
    <dc:creator>Alexander_iv</dc:creator>
    <dc:date>2023-04-26T08:07:49Z</dc:date>
    <item>
      <title>caam-keygen: using black key from a plaintext</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1640354#M204848</link>
      <description>&lt;P&gt;caam-keygen supports generating a black key from plaintext. Is it possible to:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. decrypting data from one device on another if the keys were generated with the same plaintext? (OTPMKs are different)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2. using this plaintext as a key for dmsetup and preparing an image, for example, on a host machine, and later mounting the image on a device using a black key generated with the same plaintext?&lt;/P&gt;&lt;P&gt;In other words, is plaintext interpreted as a symmetric key and used for encryption/decryption? Or is it just some modifier that allows generating black keys similarly on the same/different devices?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 08:07:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1640354#M204848</guid>
      <dc:creator>Alexander_iv</dc:creator>
      <dc:date>2023-04-26T08:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: caam-keygen: using black key from a plaintext</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641495#M204954</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/216395"&gt;@Alexander_iv&lt;/a&gt;&amp;nbsp;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope you are doing well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Q)is plaintext interpreted as a symmetric key and used for encryption/decryption?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-&amp;gt;It makes an encryption key out of plain text or data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;$ ./caam-keygen&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create &amp;lt;key_name&amp;gt; &amp;lt;key_enc&amp;gt; &amp;lt;key_mode&amp;gt; &amp;lt;key_val&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Where using key mode we can generate a black key from a plaintext given in the next argument or generate a black key from random with the size given in the next argument.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have mentioned the example for the reference as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-&amp;gt;To generate a random black key encrypted with CCM from a plaintext of 24 bytes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;./caam-keygen create randomkeyCCM ccm -s 24&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please refer to this doc for in-depth details.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/172311/1/AN12714_iMX%20Encrypted%20Storage%20Using%20CAAM%20Secure%20Keys.pdf" target="_blank" rel="noopener" data-saferedirecturl="https://www.google.com/url?q=https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/172311/1/AN12714_iMX%2520Encrypted%2520Storage%2520Using%2520CAAM%2520Secure%2520Keys.pdf&amp;amp;source=gmail&amp;amp;ust=1682674935794000&amp;amp;usg=AOvVaw2OtVwxSyMP-YTeHB1JB-dT"&gt;https://community.nxp.com/&lt;WBR /&gt;pwmxy87654/attachments/&lt;WBR /&gt;pwmxy87654/imx-processors/&lt;WBR /&gt;172311/1/AN12714_iMX%&lt;WBR /&gt;20Encrypted%20Storage%20Using%&lt;WBR /&gt;20CAAM%20Secure%20Keys.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this information helps you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &amp;amp; Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sanket Parekh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 10:20:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641495#M204954</guid>
      <dc:creator>Sanket_Parekh</dc:creator>
      <dc:date>2023-04-27T10:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: caam-keygen: using black key from a plaintext</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641580#M204961</link>
      <description>&lt;P&gt;Thank you for your answer. My question was mostly about using a key for encrypting something on one host/board and decrypting it on another, which has that key as a black key.&lt;/P&gt;&lt;P&gt;Some experiments showed it's possible. I just put some notes here. It could be helpful in the future.&lt;/P&gt;&lt;P&gt;Preparing key &amp;amp; encrypted partition on a host&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#!/bin/bash

LOOPDEV=/dev/loop0
DMPART=/dev/mapper/encrypted-tmp
KEY="782DBC901C72F00E8E7A318EC98CF49BB564D5D3723CC0600FDE547DF0E43E4A"
MNTDIR=/tmp/mnt

# Create raw file
dd if=/dev/zero of=./data.img bs=1M count=16

# Mount the raw file and create FS on it
sudo losetup $LOOPDEV ./data.img
sudo dmsetup -v create encrypted-tmp --table "0 16384 crypt capi:ecb(aes) $KEY 0 $LOOPDEV 0 1 sector_size:512"
sudo mkfs.ext4 $DMPART
sync

mkdir -p $MNTDIR
sudo mount $DMPART $MNTDIR

# Mark
sudo touch $MNTDIR/crypto-shripto

# Sync &amp;amp; unmount
sync
sudo umount $DMPART
sudo dmsetup remove encrypted-tmp
sudo losetup -d $LOOPDEV

# Export key in caam-keygen format
echo $KEY | xxd -r -p &amp;gt; caam.key.txt

# data.img &amp;amp; caam.key.txt are ready for export on a board&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Creating BB key from the key &amp;amp; mounting encrypted partition on a device&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#!/bin/bash

# it's differs from default caam-keygen
KEYSTORAGE=/run/caam/keys/
LOOPDEV=/dev/loop5
MNTDIR=/tmp/mnt/
DMDEV=/dev/mapper/encrypted
KEYNAME=mountkey
# create black key
caam-keygen create $KEYNAME ecb -t $(cat caam.key.txt)

# import black key to keyctl
cat $KEYSTORAGE/$KEYNAME | keyctl padd logon $KEYNAME: @s

mkdir -p /tmp/mnt

losetup $LOOPDEV data.img
dmsetup -v create encrypted --table "0 $(blockdev --getsz $LOOPDEV) crypt capi:tk(ecb(aes)) :52:logon:$KEYNAME: 0 $LOOPDEV 0 1 sector_size:512"
mount $DMDEV $MNTDIR
ls -l $MNTDIR&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 12:30:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641580#M204961</guid>
      <dc:creator>Alexander_iv</dc:creator>
      <dc:date>2023-04-27T12:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: caam-keygen: using black key from a plaintext</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641946#M204998</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/216395"&gt;@Alexander_iv&lt;/a&gt;&amp;nbsp;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for sharing it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It'd be really helpful for the others to get a reference from it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &amp;amp; Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sanket Parekh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 04:48:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/caam-keygen-using-black-key-from-a-plaintext/m-p/1641946#M204998</guid>
      <dc:creator>Sanket_Parekh</dc:creator>
      <dc:date>2023-04-28T04:48:17Z</dc:date>
    </item>
  </channel>
</rss>

