<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://ess-wiki.advantech.com.tw/wiki/index.php?action=history&amp;feed=atom&amp;title=ASR-A501_TPM</id>
		<title>ASR-A501 TPM - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://ess-wiki.advantech.com.tw/wiki/index.php?action=history&amp;feed=atom&amp;title=ASR-A501_TPM"/>
		<link rel="alternate" type="text/html" href="https://ess-wiki.advantech.com.tw/wiki/index.php?title=ASR-A501_TPM&amp;action=history"/>
		<updated>2026-04-20T21:47:50Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.28.3</generator>

	<entry>
		<id>https://ess-wiki.advantech.com.tw/wiki/index.php?title=ASR-A501_TPM&amp;diff=39719&amp;oldid=prev</id>
		<title>Xingxing.li: Created page with &quot; The Trusted Platform Module (TPM) is a hardware chip that safeguards the security of computer systems. It can securely store sensitive data, preventing it from being stolen....&quot;</title>
		<link rel="alternate" type="text/html" href="https://ess-wiki.advantech.com.tw/wiki/index.php?title=ASR-A501_TPM&amp;diff=39719&amp;oldid=prev"/>
				<updated>2025-06-06T07:16:40Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; The Trusted Platform Module (TPM) is a hardware chip that safeguards the security of computer systems. It can securely store sensitive data, preventing it from being stolen....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
The Trusted Platform Module (TPM) is a hardware chip that safeguards the security of computer systems. It can securely store sensitive data, preventing it from being stolen. It generates unique identifiers based on hardware and software configurations, which are used for platform authentication. Additionally, it can serve as a hardware random number generator and an encryption accelerator.&lt;br /&gt;
&lt;br /&gt;
ASR-A501 supports one external tpm.&lt;br /&gt;
&lt;br /&gt;
=== '''Check TPM Device''' ===&lt;br /&gt;
&lt;br /&gt;
List tpm device&lt;br /&gt;
&amp;lt;pre&amp;gt;# ls /dev/tpm*&lt;br /&gt;
/dev/tpm0 /dev/tpmrm0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to check tpm activity with the following command.&lt;br /&gt;
&amp;lt;pre&amp;gt;# i2cdump –f –y 6 0x2e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Usage''' ===&lt;br /&gt;
&lt;br /&gt;
Here are two ways to use tpm:&lt;br /&gt;
&lt;br /&gt;
1. Python scripts&amp;amp;nbsp;Python scripts can be used to send simple commands to the TPM device. For instance, hereafter is a simple script for sending a TPM2_GetRandom command and requesting 16 random bytes.&lt;br /&gt;
&amp;lt;pre&amp;gt;import binascii&lt;br /&gt;
with open('/dev/tpm0','r+b',buffering=0) as tpm : tpm.write(binascii.unhexlify(b'80010000000c0000017b0010')) print(tpm.read())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After writing the desired code to a file (for instance named TPM2_GetRandom.py), execute it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;# python3 TPM2_GetRandom.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. C language scripts&amp;amp;nbsp;In the same way as Python scripts, C language scripts can be used to send commands to the TPM device. The previous example for sending a TPM2_GetRandom command and requesting 16 random bytes is also achieved with the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main() { &lt;br /&gt;
FILE *tpm; char str[] = &amp;quot;\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x7b\x00\x10&amp;quot;; &lt;br /&gt;
char buffer[100]; int i, n; &lt;br /&gt;
tpm = fopen(&amp;quot;/dev/tpm0&amp;quot;, &amp;quot;rb+&amp;quot;); &lt;br /&gt;
if (tpm == NULL){ &lt;br /&gt;
printf(&amp;quot;ERROR: Could not open driver file.\n&amp;quot;);&lt;br /&gt;
return -1; &lt;br /&gt;
} &lt;br /&gt;
n=fwrite(str, 1, sizeof(str), tpm); &lt;br /&gt;
if (n != sizeof(str)){ printf(&amp;quot;ERROR: Could not write bytes to TPM.\n&amp;quot;);&lt;br /&gt;
fclose(tpm); return -1; } n = fread(buffer, 1, sizeof(buffer), tpm); &lt;br /&gt;
printf(&amp;quot;TPM Response: &amp;quot;);&lt;br /&gt;
for (i=0; i&amp;lt;n; i++){ printf(&amp;quot;%x &amp;quot;, buffer[i]); } &lt;br /&gt;
printf(&amp;quot;\n&amp;quot;); fclose(tpm); return 0; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save these instructions to a TPM2_GetRandom.c file. C language scripts are different from Python scripts because they have to be compiled before they are executed by the terminal. To compile the script, use the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;# gcc TPM2_GetRandom.c -o TPM2_GetRandom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then to execute the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;# ./TPM2_GetRandom&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xingxing.li</name></author>	</entry>

	</feed>