def sign(self, key, data, mecha=MechanismRSAPKCS1):
m = mecha.to_native()<EOL>signature = ckbytelist()<EOL>data1 = ckbytelist(data)<EOL>rv = self.lib.C_SignInit(self.session, m, key)<EOL>if rv != CKR_OK:<EOL><INDENT>raise PyKCS11Error(rv)<EOL><DEDENT>rv = self.lib.C_Sign(self.session, data1, signature)<EOL>if rv != CKR_OK:<EOL><INDENT>raise PyKCS11Error(rv)<EOL><DEDENT>rv = self.lib.C_Sign(self.session, data1, signature)<EOL>if rv != CKR_OK:<EOL><INDENT>raise PyKCS11Error(rv)<EOL><DEDENT>return signature<EOL>
C_SignInit/C_Sign

:param key: a key handle, obtained calling :func:`findObjects`.
:type key: integer
:param data: the data to be signed
:type data:  (binary) string or list/tuple of bytes
:param mecha: the signing mechanism to be used
  (use `MechanismRSAPKCS1` for `CKM_RSA_PKCS`)
:type mecha: :class:`Mechanism`
:return: the computed signature
:rtype: list of bytes

:note: the returned value is an instance of :class:`ckbytelist`.
  You can easly convert it to a binary string with:
  ``bytes(ckbytelistSignature)``
  or, for Python 2:
  ``''.join(chr(i) for i in ckbytelistSignature)``