FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cryptoauthlib/python/tests/test_tng.py at main · rrottmann/cryptoauthlib · GitHub
rrottmann
/
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
/
tests
/
test_tng.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
120 lines (87 loc) · 4.2 KB
Breadcrumbs
cryptoauthlib
/
python
/
tests
/
test_tng.py
Copy path
File metadata and controls
120 lines (87 loc) · 4.2 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
import
pytest
from
cryptoauthlib
import
*
from
cryptoauthlib
.
library
import
load_cryptoauthlib
,
get_size_by_name
from
cryptoauthlib_mock
import
atcab_mock
@
pytest
.
fixture
def
test_tng_init
():
"""
Run tests against the library mock
"""
load_cryptoauthlib
(
atcab_mock
())
@
pytest
.
fixture
def
test_tng_init_lib
(
test_init_with_lib
):
"""
Run tests against a built library on the platform
"""
load_cryptoauthlib
()
@
pytest
.
fixture
def
test_tng_init_live
(
test_init_with_device
):
"""
Use real hardware for these tests - otherwise skip
"""
load_cryptoauthlib
()
if
Status
.
ATCA_SUCCESS
!=
atcab_init
(
cfg_ateccx08a_kithid_default
()):
raise
Exception
(
'Unable to connect to a device'
)
def
test_tng_get_device_pubkey
(
test_tng_init
):
public_key
=
bytearray
(
64
)
assert
tng_get_device_pubkey
(
public_key
)
==
Status
.
ATCA_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
def
test_tng_atcacert_max_device_cert_size
(
test_tng_init
):
max_cert_size
=
AtcaReference
(
0
)
assert
tng_atcacert_max_device_cert_size
(
max_cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
max_cert_size
.
value
==
atcab_mock
.
r_max_cert_size
.
value
def
test_tng_atcacert_read_device_cert_no_signer
(
test_tng_init
):
cert
=
bytearray
(
1024
)
cert_size
=
AtcaReference
(
len
(
cert
))
assert
tng_atcacert_read_device_cert
(
cert
,
cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
cert_size
.
value
==
atcab_mock
.
r_cert_size
.
value
assert
cert
==
bytearray
(
atcab_mock
.
r_cert
)
def
test_tng_atcacert_read_device_cert_signer
(
test_tng_init
):
cert
=
bytearray
(
1024
)
cert_size
=
AtcaReference
(
len
(
cert
))
signer_cert
=
bytes
(
512
)
assert
tng_atcacert_read_device_cert
(
cert
,
cert_size
,
signer_cert
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
cert_size
.
value
==
atcab_mock
.
r_cert_size
.
value
assert
cert
==
bytearray
(
atcab_mock
.
r_cert
)
def
test_tng_atcacert_device_public_key_no_cert
(
test_tng_init
):
public_key
=
bytearray
(
64
)
assert
tng_atcacert_device_public_key
(
public_key
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
def
test_tng_atcacert_device_public_key_cert
(
test_tng_init
):
public_key
=
bytearray
(
64
)
cert
=
bytes
(
512
)
assert
tng_atcacert_device_public_key
(
public_key
,
cert
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
def
test_tng_atcacert_max_signer_cert_size
(
test_tng_init
):
max_cert_size
=
AtcaReference
(
0
)
assert
tng_atcacert_max_signer_cert_size
(
max_cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
max_cert_size
.
value
==
atcab_mock
.
r_max_cert_size
.
value
def
test_tng_atcacert_read_device_cert
(
test_tng_init
):
cert
=
bytearray
(
1024
)
cert_size
=
AtcaReference
(
len
(
cert
))
assert
tng_atcacert_read_signer_cert
(
cert
,
cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
cert_size
.
value
==
atcab_mock
.
r_cert_size
.
value
assert
cert
==
bytearray
(
atcab_mock
.
r_cert
)
def
test_tng_atcacert_signer_public_key_no_cert
(
test_tng_init
):
public_key
=
bytearray
(
64
)
assert
tng_atcacert_signer_public_key
(
public_key
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
def
test_tng_atcacert_signer_public_key_cert
(
test_tng_init
):
public_key
=
bytearray
(
64
)
cert
=
bytes
(
512
)
assert
tng_atcacert_signer_public_key
(
public_key
,
cert
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
def
test_tng_atcacert_root_cert_size
(
test_tng_init
):
cert_size
=
AtcaReference
(
0
)
assert
tng_atcacert_root_cert_size
(
cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
cert_size
.
value
==
atcab_mock
.
r_cert_size
.
value
def
test_tng_atcacert_root_cert
(
test_tng_init
):
cert
=
bytearray
(
1024
)
cert_size
=
AtcaReference
(
len
(
cert
))
assert
tng_atcacert_root_cert
(
cert
,
cert_size
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
cert_size
.
value
==
atcab_mock
.
r_cert_size
.
value
assert
cert
==
bytearray
(
atcab_mock
.
r_cert
)
def
test_tng_atcacert_root_public_key
(
test_tng_init
):
public_key
=
bytearray
(
64
)
assert
tng_atcacert_root_public_key
(
public_key
)
==
CertStatus
.
ATCACERT_E_SUCCESS
assert
public_key
==
bytearray
(
atcab_mock
.
r_genkey_pubkey
)
Back
|
FazBrowse Home
|
New Git URL