Code generation from protected simulink model (p-code or binaries???)
5 views (last 30 days)
Show older comments
We have shared a protected simulink model with our clients, which they require to generate code from it to use within a third party software. I know that you can set the protected model to allow code generation an they are several options to "hide" the code. I know that the p-code (obfuscated) option does not completely hide the code...
But what about the binaries option? Does it better protect/encrypt the source code?
Thank you
0 Comments
Answers (2)
Sherman
on 6 May 2015
Hi Iker,
There are a number of trade-offs to consider when deciding how to protect your model. I'll discuss some relevant ones below:
Obfuscated code will allow your client to generate and recompile the code for another target. Binaries (although more secure) will only allow them access to the compiled .lib files that the original unprotected model was configured to generate.
Note that the obfuscated option does not create p-code (p-code is only created from MATLAB .m files). It creates obfuscated C code from your model. If you are running 14b or later, you can actually use your own code obfuscator with the model protection process via a callback hook (you can take a look at commercial solutions such as Stunnix and see if they meet your needs). http://www.mathworks.com/help/rtw/ug/specify-custom-obfuscator-for-protected-model.html
Also note that obfuscation is not foolproof. It will discourage casual inspection but you need strong encryption to be really secure (we provide encryption as of 13b). The catch is that your client needs to be able to decrypt your code in order to compile it so the encryption will really only protect against unauthorized third parties.
For your use case, it sounds like you need to provide your customers with actual source code since they are recompiling it with their third party software. In this case, you likely need to set the 'GenerateCodeOnly' flag in the unprotected model prior to protecting the model. While protecting the model, you also have to choose obfuscated code and either use the Simulink built-in obfuscator or your own.
HTH
-S
0 Comments
Jonathan Stevenson
on 11 Jul 2016
Does this work in MATLAB 2012b? Where is the option to generated Protected Simulink Block in the Simulink version in R2012b (Version 8)?
0 Comments
See Also
Categories
Find more on Simulink Environment Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!