[其他产品] 使用Python来操作Microchip安全芯片

[复制链接]
 楼主| 发表于 2023-7-18 15:44 | 显示全部楼层
read_write示例
Read命令从设备的一个内存区域读取。数据在返回到系统之前可以选择加密。
写入命令写入设备上的EEPROM区域。
根据槽的WriteConfig字节的值,数据可能需要在发送到设备之前由系统加密
这个例子说明了明文写、明文读、加密读和加密写的使用
 楼主| 发表于 2023-7-18 15:44 | 显示全部楼层
$ python .\read_write.py -d sha

Basic Read/Write Example

Generaing data using RAND command
    Generated data:
        31 38 23 06 13 74 7E 6B 3C 3B 10 76 01 D8 3A F3
        C3 27 3F 73 22 E4 7F 64 3C 89 D6 2A B9 FA 22 0D


Write command:
    Writing data to slot 8
    Write Success

Read command:
    Reading data stored in slot 8
    Read data:
        31 38 23 06 13 74 7E 6B 3C 3B 10 76 01 D8 3A F3
        C3 27 3F 73 22 E4 7F 64 3C 89 D6 2A B9 FA 22 0D


Verifing read data matches written data:
    Data Matches!

Writing IO Protection Secret

Generaing data using RAND command
    Generated data:
        E3 C0 60 F4 6F 48 70 83 F8 C8 7F 1C B0 25 93 F0
        2B 5B F4 D8 4E 50 E8 B1 3C 5E 94 1E 76 4A 11 BF


Encrypted Write Command:
    Writing data to slot 3
    Write Success

Encrypted Read Command:
    Reading data stored in slot 3
    Read data:
        E3 C0 60 F4 6F 48 70 83 F8 C8 7F 1C B0 25 93 F0
        2B 5B F4 D8 4E 50 E8 B1 3C 5E 94 1E 76 4A 11 BF


Verifing read data matches written data:
    Data Matches!

Done
 楼主| 发表于 2023-7-18 15:44 | 显示全部楼层
ECDSA签名验证示例
Sign命令使用ECDSA算法和Slot中的私钥生成签名。

Verify命令接受ECDSA签名,并验证该签名是否由输入消息给定的摘要和公钥正确生成的。

这个例子演示了ECC Sign和Verify命令在受支持的情况下的使用加密身份验证设备以及主机端创建和验证签名的步骤。
 楼主| 发表于 2023-7-18 15:45 | 显示全部楼层
在这个例子中:

生成随机消息
消息使用私钥签名
签名消息使用关联的公钥验证
签名的创建和验证可以由设备或主机根据脚本参数执行。
 楼主| 发表于 2023-7-18 15:45 | 显示全部楼层
  1. $ python .\sign_verify.py

  2. Sign/Verify Example

  3. Signing Public key:
  4.     2A 51 36 3C 62 10 6A D5 27 8E 0B 72 ED 3A A1 B9
  5.     4E DF 3B C8 45 82 44 93 9E 18 C3 36 FB 7F A3 2C
  6.     F5 B0 47 0E 3D CE 55 7D 99 A0 56 34 BE 43 59 36
  7.     50 82 93 49 58 7B F4 2B 99 DA 3C 33 12 19 99 82

  8. Message Digest:
  9.     09 BA 4E F5 83 A1 E8 19 19 1F FD 4B 86 D5 55 0D
  10.     27 6B 4A C0 D3 54 E1 C4 FD CC 47 D6 D8 8C DC 33


  11. Signing the Message Digest
  12.     Signing with device

  13. Signature:
  14.     22 3C 80 CE F4 2C DB 55 FB 8D 5B 57 03 FB 3A 4C
  15.     0A EB 98 90 85 DC 33 7B D7 3B E8 4B B3 3E 36 C5
  16.     E0 89 C6 F6 AA 80 DC 9F 37 13 97 2D 18 ED 3D BF
  17.     62 10 0A CC 68 6B 1A 45 21 71 2E 5C 14 86 F9 98


  18. Verifing the signature:
  19.     Verifying with host
  20.     Signature is valid!

  21. Done
发表于 2023-7-19 18:51 | 显示全部楼层
看看
发表于 2023-7-19 19:46 来自手机 | 显示全部楼层
。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表