cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Key in OP Byte

bsuthar
Associate III

Hello Team,

I want to store encryption Key - 4 byte into Option Byte OR any other memory Except in-built Flash Memory.

Is it possible to write in Option Memory ? 

If not what could be the other option ? 

1 ACCEPTED SOLUTION

Accepted Solutions

@bsuthar wrote:

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.


This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804

mALLEm_1-1760781630661.png

But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!

In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:

 

mALLEm_1-1760790160599.png

Read in software:

key = *(uint32_t*)0x1FFFF804;

key contains 0x8778ED12

ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

12 REPLIES 12
TDK
Super User

There are no spare addresses in option bytes for this.

The usual method for doing this is writing them to the last page of FLASH. If you don't want to do that, you'll need to use an external memory chip.

If you feel a post has answered your question, please click "Accept as Solution".
mƎALLEm
ST Employee

Hello,

I think you can store only two bytes in the option bytes in STM32F3. (By the way you didn't mention the exact part number you are using)

mALLEm_0-1760716900743.png

The only possibility in your case (4 bytes) is to use the RTC backup registers where you need an external battery.

I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;).

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thanks , mƎALLEm

Exact Device is : STM32F303Rbt6

"I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;). "

Yes , you catched the point, :). 

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.

 

@TDK 

Whole idea is no body Should sniff the Key.

 

Thank you,

 


@bsuthar wrote:

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.


This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804

mALLEm_1-1760781630661.png

But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!

In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:

 

mALLEm_1-1760790160599.png

Read in software:

key = *(uint32_t*)0x1FFFF804;

key contains 0x8778ED12

ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@mƎALLEm , This is useful.

we will look into it.

Since, you mentioned BitInversion,  will it automatically inverted while storing this two byte in Option memory ?

If we enable RDP1 , will this two byte as well be read/Write protected ? 

Thank you,

 


@bsuthar wrote:

@mƎALLEm , This is useful.

we will look into it.

Since, you mentioned BitInversion,  will it automatically inverted while storing this two byte in Option memory ?

 

 Yes. It's automatically inverted. The inverted values are not accessible by the user. I think it is used mainly to check the consistency.

 


@bsuthar wrote:

@mƎALLEm , This is useful.

If we enable RDP1 , will this two byte as well be read/Write protected ? 

Thank you,


Emm that's a good question. I'm not expert of security subjects. You can ask it in the STM32 Security forum but according to the AN4758 "Proprietary code read-out protection on
STM32L4, STM32L4+, STM32G4 and STM32WB Series"

mALLEm_0-1761054591501.png

Both Option bytes and Back-up registers are accessible at RDP1. So I think you need to use the internal Flash. No way ..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@mƎALLEm ,

Sorry for delay reply as we were on new Year Holiday.

You are saying :

"Both Option bytes and Back-up registers are accessible at RDP1. So I think you need to use the internal Flash. No way .."

Are you pointing out because of limittaion of 4 byte storage ?. we can shrink Key to 2 byte to be stored in Option Byte. 

 


@bsuthar wrote:

@mƎALLEm ,

Are you pointing out because of limittaion of 4 byte storage ?. we can shrink Key to 2 byte to be stored in Option Byte. 


No, I'm saying that option bytes are not protected by RDP1. Please read my previous post. Meanwhile you can confirm by asking that question in STM32 Security forum as I'm not a security expert guy.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@mƎALLEm ,

Got It.

Thank you for your Support.