def decrypt(self, ciphertext): """ Decrypts **ciphertext**, using the private key data in the object. The ciphertext's length must be equal to: **self.output_size** Returns a string containing the plaintext. """ ciphertext = t2b(ciphertext) plaintext = t2b("\0" * self.output_size) ret = _lib.wc_RsaPrivateDecrypt(ciphertext, len(ciphertext), plaintext, len(plaintext), self.native_object) if ret < 0: raise WolfCryptError("Decryption error (%d)" % ret) return plaintext[:ret]
def decrypt(self, ciphertext): """ Decrypts **ciphertext**, using the private key data in the object. The ciphertext's length must be equal to: **self.output_size** Returns a string containing the plaintext. """ ciphertext = t2b(ciphertext) plaintext = _ffi.new("byte[%d]" % self.output_size) ret = _lib.wc_RsaPrivateDecrypt(ciphertext, len(ciphertext), plaintext, self.output_size, self.native_object) if ret < 0: # pragma: no cover raise WolfCryptError("Decryption error (%d)" % ret) return _ffi.buffer(plaintext, ret)[:]