FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cryptoauthlib/python/cryptoauthlib/device.py at main · duslabo/cryptoauthlib · GitHub
duslabo
/
cryptoauthlib
Public
forked from
MicrochipTech/cryptoauthlib
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cryptoauthlib
/
python
/
cryptoauthlib
/
device.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
233 lines (196 loc) · 8.05 KB
Breadcrumbs
cryptoauthlib
/
python
/
cryptoauthlib
/
device.py
Copy path
File metadata and controls
233 lines (196 loc) · 8.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
"""
Cryptoauthlib Device Configuration
"""
# (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#
# Subject to your compliance with these terms, you may use Microchip software
# and any derivatives exclusively with Microchip products. It is your
# responsibility to comply with third party license terms applicable to your
# use of third party software (including open source software) that may
# accompany Microchip software.
#
# THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
# EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
# WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
# PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT,
# SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE
# OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
# MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
# FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL
# LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED
# THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR
# THIS SOFTWARE.
from
ctypes
import
Structure
,
c_uint16
,
c_uint8
from
.
library
import
AtcaStructure
# Because this module directly mirrors the C api the following is an exception to the python coding standard
# pylint: disable-msg=too-few-public-methods
class
AesEnable
(
Structure
):
"""AES Enable (608) Field Definition """
_fields_
=
[(
'Enable'
,
c_uint8
,
1
),
(
'Reserved'
,
c_uint8
,
6
)]
_pack_
=
1
class
I2cEnable
(
Structure
):
"""I2C Enable Field Definition """
_fields_
=
[(
'Enable'
,
c_uint8
,
1
),
(
'Reserved'
,
c_uint8
,
6
)]
_pack_
=
1
class
CountMatch
(
Structure
):
"""CountMatch (608) Field Definition """
_fields_
=
[(
'Enable'
,
c_uint8
,
1
),
(
'Reserved'
,
c_uint8
,
3
),
(
'CountMatchKey'
,
c_uint8
,
4
)]
_pack_
=
1
class
ChipMode508
(
Structure
):
"""ChipMode for 508 Field Definition """
_fields_
=
[(
'UserExtraAdd'
,
c_uint8
,
1
),
(
'TTLenable'
,
c_uint8
,
1
),
(
'WatchdogDuration'
,
c_uint8
,
1
)]
_pack_
=
1
class
ChipMode608
(
Structure
):
"""ChipMode for 608 Field Definition """
_fields_
=
[(
'UserExtraAdd'
,
c_uint8
,
1
),
(
'TTLenable'
,
c_uint8
,
1
),
(
'WatchdogDuration'
,
c_uint8
,
1
),
(
'ClockDivider'
,
c_uint8
,
5
)]
_pack_
=
1
class
Counter204
(
Structure
):
"""Counter Definition for SHA204 """
_fields_
=
[(
'UseFlag'
,
c_uint8
),
(
'UpdateCount'
,
c_uint8
)]
_pack_
=
1
class
SlotConfig
(
Structure
):
"""Slot Configuration Field Definition """
_fields_
=
[(
'ReadKey'
,
c_uint16
,
4
),
(
'NoMac'
,
c_uint16
,
1
),
(
'LimitedUse'
,
c_uint16
,
1
),
(
'EncryptRead'
,
c_uint16
,
1
),
(
'IsSecret'
,
c_uint16
,
1
),
(
'WriteKey'
,
c_uint16
,
4
),
(
'WriteConfig'
,
c_uint16
,
4
)]
_pack_
=
1
class
UseLock
(
Structure
):
"""UseLock Field Definition """
_fields_
=
[(
'UseLockEnable'
,
c_uint8
,
4
),
(
'UseLockKey'
,
c_uint8
,
4
)]
_pack_
=
1
class
VolatileKeyPermission
(
Structure
):
"""VolatileKeyPermission Field Definition """
_fields_
=
[(
'VolatileKeyPermitSlot'
,
c_uint8
,
4
),
(
'Reserved'
,
c_uint8
,
3
),
(
'VolatileKeyPermitEnable'
,
c_uint8
,
1
)]
_pack_
=
1
class
SecureBoot
(
Structure
):
"""SecureBoot Field Definition """
_fields_
=
[(
'SecureBootMode'
,
c_uint16
,
2
),
(
'Reserved0'
,
c_uint16
,
1
),
(
'SecureBootPersistentEnable'
,
c_uint16
,
1
),
(
'SecureBootRandNonce'
,
c_uint16
,
1
),
(
'Reserved1'
,
c_uint16
,
3
),
(
'SecureBootSigDig'
,
c_uint16
,
4
),
(
'SecureBootPubKey'
,
c_uint16
,
4
)]
_pack_
=
1
class
ChipOptions
(
Structure
):
"""ChipOptions Field Definition """
_fields_
=
[(
'PowerOnSelfTest'
,
c_uint16
,
1
),
(
'IoProtectionKeyEnable'
,
c_uint16
,
1
),
(
'KdfAesEnable'
,
c_uint16
,
1
),
(
'AutoClearFirstFail'
,
c_uint16
,
1
),
(
'Reserved'
,
c_uint16
,
4
),
(
'EcdhProtectionBits'
,
c_uint16
,
2
),
(
'KdfProtectionBits'
,
c_uint16
,
2
),
(
'IoProtectionKey'
,
c_uint16
,
4
)]
_pack_
=
1
class
X509Format
(
Structure
):
"""X509Format Field Definition """
_fields_
=
[(
'PublicPosition'
,
c_uint8
,
4
),
(
'TemplateLength'
,
c_uint8
,
4
)]
_pack_
=
1
class
KeyConfig
(
Structure
):
"""KeyConfig Field Definition """
_fields_
=
[(
'Private'
,
c_uint16
,
1
),
(
'PubInfo'
,
c_uint16
,
1
),
(
'KeyType'
,
c_uint16
,
3
),
(
'Lockable'
,
c_uint16
,
1
),
(
'ReqRandom'
,
c_uint16
,
1
),
(
'ReqAuth'
,
c_uint16
,
1
),
(
'AuthKey'
,
c_uint16
,
4
),
(
'PersistentDisable'
,
c_uint16
,
1
),
(
'RFU'
,
c_uint16
,
1
),
(
'X509id'
,
c_uint16
,
2
)]
_pack_
=
1
class
Atsha204aConfig
(
AtcaStructure
):
"""ATSHA204A Config Zone Definition """
_fields_
=
[(
'SN03'
,
c_uint8
*
4
),
(
'RevNum'
,
c_uint8
*
4
),
(
'SN48'
,
c_uint8
*
5
),
(
'Reserved13'
,
c_uint8
),
(
'I2C_Enable'
,
I2cEnable
),
(
'Reserved15'
,
c_uint8
),
(
'I2C_Address'
,
c_uint8
),
(
'CheckMacConfig'
,
c_uint8
),
(
'OTPmode'
,
c_uint8
),
(
'SelectorMode'
,
c_uint8
),
(
'SlotConfig'
,
SlotConfig
*
16
),
(
'Counter'
,
Counter204
*
8
),
(
'LastKeyUse'
,
c_uint8
*
16
),
(
'UserExtra'
,
c_uint8
),
(
'Selector'
,
c_uint8
),
(
'LockValue'
,
c_uint8
),
(
'LockConfig'
,
c_uint8
)]
_pack_
=
1
class
Atecc508aConfig
(
AtcaStructure
):
"""ATECC508A Config Zone Definition """
_fields_
=
[(
'SN03'
,
c_uint8
*
4
),
(
'RevNum'
,
c_uint8
*
4
),
(
'SN48'
,
c_uint8
*
5
),
(
'Reserved13'
,
c_uint8
),
(
'I2C_Enable'
,
I2cEnable
),
(
'Reserved15'
,
c_uint8
),
(
'I2C_Address'
,
c_uint8
),
(
'Reserved17'
,
c_uint8
),
(
'OTPmode'
,
c_uint8
),
(
'ChipMode'
,
ChipMode508
),
(
'SlotConfig'
,
SlotConfig
*
16
),
(
'Counter0'
,
c_uint8
*
8
),
(
'Counter1'
,
c_uint8
*
8
),
(
'LastKeyUse'
,
c_uint8
*
16
),
(
'UserExtra'
,
c_uint8
),
(
'Selector'
,
c_uint8
),
(
'LockValue'
,
c_uint8
),
(
'LockConfig'
,
c_uint8
),
(
'SlotLocked'
,
c_uint16
),
(
'RFU'
,
c_uint16
),
(
'X509format'
,
X509Format
*
4
),
(
'KeyConfig'
,
KeyConfig
*
16
)]
_pack_
=
1
class
Atecc608Config
(
AtcaStructure
):
"""ATECC608 Config Zone Definition """
_fields_
=
[(
'SN03'
,
c_uint8
*
4
),
(
'RevNum'
,
c_uint8
*
4
),
(
'SN48'
,
c_uint8
*
5
),
(
'AES_Enable'
,
AesEnable
),
(
'I2C_Enable'
,
I2cEnable
),
(
'Reserved15'
,
c_uint8
),
(
'I2C_Address'
,
c_uint8
),
(
'Reserved17'
,
c_uint8
),
(
'CountMatch'
,
CountMatch
),
(
'ChipMode'
,
ChipMode608
),
(
'SlotConfig'
,
SlotConfig
*
16
),
(
'Counter0'
,
c_uint8
*
8
),
(
'Counter1'
,
c_uint8
*
8
),
(
'UseLock'
,
UseLock
),
(
'VolatileKeyPermission'
,
VolatileKeyPermission
),
(
'SecureBoot'
,
SecureBoot
),
(
'KdfIvLoc'
,
c_uint8
),
(
'KdfIvStr'
,
c_uint8
*
2
),
(
'Reserved68'
,
c_uint8
*
9
),
(
'UserExtra'
,
c_uint8
),
(
'UserExtraAdd'
,
c_uint8
),
(
'LockValue'
,
c_uint8
),
(
'LockConfig'
,
c_uint8
),
(
'SlotLocked'
,
c_uint16
),
(
'ChipOptions'
,
ChipOptions
),
(
'X509format'
,
X509Format
*
4
),
(
'KeyConfig'
,
KeyConfig
*
16
)]
_pack_
=
1
__all__
=
[
'Atsha204aConfig'
,
'Atecc508aConfig'
,
'Atecc608Config'
]
Back
|
FazBrowse Home
|
New Git URL