def load_rsa_public_numbers(self, numbers):
rsa._check_public_key_components(numbers.e, numbers.n)
attrs = build_attributes([
(self._binding.CKA_TOKEN, False), # don't persist it
(self._binding.CKA_CLASS, self._binding.CKO_PUBLIC_KEY),
(self._binding.CKA_KEY_TYPE, self._binding.CKK_RSA),
(self._binding.CKA_MODULUS, utils.int_to_bytes(numbers.n)),
(self._binding.CKA_PUBLIC_EXPONENT, utils.int_to_bytes(numbers.e)),
], self)
session = self._session_pool.acquire()
# TODO: do we want to delete the object from the session when it
# is no longer in scope?
object_handle = self._ffi.new("CK_OBJECT_HANDLE *")
res = self._lib.C_CreateObject(
session[0], attrs.template, len(attrs.template), object_handle
)
self._check_error(res)
return _RSAPublicKey(self, object_handle[0])
评论列表
文章目录