linux-imx/include/soc/fsl/dcp-blob.h
Kshitiz Varshney 35f3816c21 DCP: Add AES OTP keys support
Current DCP driver implementation doesn't support AES OTP CRYPTO_KEY.
otp_unique_key & otp_crypto_key handles are generated by U-boot RNG driver
and on each reboot cycle, device tree fix-up is done using RNG.

OpenSSL application can input device tree fixed up 16 byte number for
crypto operations.

Tested on i.MX6ULL EVK with commands below.

- Encrypt using UNIQUE_KEY:
$ openssl aes-128-ecb -p -nosalt -nopad -K "$(hexdump -v -e '"" 1/1 "%02X"'\
/proc/device-tree/soc/bus@2200000/crypto@2280000/otp_unique_key)" -in  \
openssl_test.txt -out my_encrypted_secret.bin

- Decrypt using UNIQUE_KEY:
$ openssl aes-128-ecb -d -p -nosalt -nopad -K "$(hexdump -v -e '"" 1/1 "%02X"'\
/proc/device-tree/soc/bus@2200000/crypto@2280000/otp_unique_key)" -in  \
my_encrypted_secret.bin -out openssl_decrypt_test.txt

- Encrypt using CRYPTO_KEY:
$ openssl aes-128-ecb -p -nosalt -nopad -K "$(hexdump -v -e '"" 1/1 "%02X"'\
 /proc/device-tree/soc/bus@2200000/crypto@2280000/otp_crypto_key)" -in  \
openssl_test.txt -out my_encrypted_secret.bin

- Decrypt using CRYPTO_KEY:
$ openssl aes-128-ecb -d -p -nosalt -nopad -K "$(hexdump -v -e '"" 1/1 "%02X"'\
 /proc/device-tree/soc/bus@2200000/crypto@2280000/otp_crypto_key)" -in \
my_encrypted_secret.bin -out openssl_decrypt_test.txt

Signed-off-by: Kshitiz Varshney <kshitiz.varshney@nxp.com>
Reviewed by: Gaurav Jain <gaurav.jain@nxp.com>
2023-10-30 17:43:50 +08:00

22 lines
394 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2022 NXP
*/
#ifndef __DCP_BLOB_H__
#define __DCP_BLOB_H__
#define MAX_KEY_SIZE 128
#define MAX_BLOB_SIZE 512
struct dcp_key_payload {
unsigned int key_len;
unsigned int blob_len;
unsigned char *key;
unsigned char *blob;
};
int mxs_dcp_blob_to_key(struct dcp_key_payload *p);
#endif