Skip to content

Commit 0576e59

Browse files
committed
mypy: fixing p256keypair.py
1 parent f28ddb5 commit 0576e59

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/controller/python/chip/crypto/p256keypair.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import abc
1919
import hashlib
20-
from ctypes import CFUNCTYPE, POINTER, c_bool, c_char, c_size_t, c_uint8, c_uint32, c_void_p, memmove, py_object, string_at
20+
from ctypes import CFUNCTYPE, POINTER, pointer, c_bool, c_char, c_size_t, c_uint8, c_uint32, c_void_p, memmove, py_object, string_at, cast
2121

2222
from chip import native
2323
from ecdsa import ECDH, NIST256p, SigningKey # type: ignore
@@ -31,18 +31,18 @@
3131

3232

3333
@ _pychip_P256Keypair_ECDSA_sign_msg_func
34-
def _pychip_ECDSA_sign_msg(self_: 'P256Keypair', message_buf: POINTER(c_uint8), message_size: int, signature_buf: POINTER(c_uint8), signature_buf_size: POINTER(c_size_t)) -> bool:
34+
def _pychip_ECDSA_sign_msg(self_: 'P256Keypair', message_buf: pointer[c_uint8], message_size: int, signature_buf: pointer[c_uint8], signature_buf_size: pointer[c_size_t]) -> bool:
3535
res = self_.ECDSA_sign_msg(string_at(message_buf, message_size)[:])
3636
memmove(signature_buf, res, len(res))
37-
signature_buf_size.content = len(res)
37+
signature_buf_size.contents.value = len(res)
3838
return True
3939

4040

4141
@ _pychip_P256Keypair_ECDH_derive_secret_func
42-
def _pychip_ECDH_derive_secret(self_: 'P256Keypair', remote_pubkey: POINTER(c_uint8), out_secret_buf: POINTER(c_uint8), out_secret_buf_size: POINTER(c_uint32)) -> bool:
42+
def _pychip_ECDH_derive_secret(self_: 'P256Keypair', remote_pubkey: pointer[c_uint8], out_secret_buf: pointer[c_uint8], out_secret_buf_size: pointer[c_uint32]) -> bool:
4343
res = self_.ECDH_derive_secret(string_at(remote_pubkey, P256_PUBLIC_KEY_LENGTH)[:])
4444
memmove(out_secret_buf, res, len(res))
45-
out_secret_buf_size.content = len(res)
45+
out_secret_buf_size.contents.value = len(res)
4646
return True
4747

4848

@@ -79,7 +79,7 @@ def _create_native_object(self) -> c_void_p:
7979
def __del__(self):
8080
if self._native_obj is not None:
8181
handle = native.GetLibraryHandle()
82-
handle.pychip_DeleteP256Keypair(c_void_p(self._native_obj))
82+
handle.pychip_DeleteP256Keypair(cast(self._native_obj, c_void_p))
8383
self._native_obj = None
8484

8585
@property
@@ -95,7 +95,7 @@ def UpdatePublicKey(self) -> None:
9595
generates a new keypair.
9696
'''
9797
handle = native.GetLibraryHandle()
98-
handle.pychip_P256Keypair_UpdatePubkey(c_void_p(self.native_object), self.public_key, len(self.public_key)).raise_on_error()
98+
handle.pychip_P256Keypair_UpdatePubkey(cast(self._native_obj, c_void_p), self.public_key, len(self.public_key)).raise_on_error()
9999

100100
@abc.abstractproperty
101101
def public_key(self) -> bytes:

0 commit comments

Comments
 (0)