Encrypts information for ``RNS.Destination.SINGLE`` or ``RNS.Destination.GROUP`` type destination. :param plaintext: A *bytes-like* containing the plaintext to be encrypted. :raises: ``ValueError`` if destination does not hold a necessary key for encryption. */ virtual*/
| 451 | :raises: ``ValueError`` if destination does not hold a necessary key for encryption. |
| 452 | */ |
| 453 | /*virtual*/ const Bytes Destination::encrypt(const Bytes& data) { |
| 454 | assert(_object); |
| 455 | TRACE("Destination::encrypt: encrypting data..."); |
| 456 | |
| 457 | if (_object->_type == PLAIN) { |
| 458 | return data; |
| 459 | } |
| 460 | |
| 461 | if (_object->_type == SINGLE && _object->_identity) { |
| 462 | return _object->_identity.encrypt(data); |
| 463 | } |
| 464 | |
| 465 | // TODO |
| 466 | /* |
| 467 | if (_object->_type == GROUP { |
| 468 | if hasattr(self, "prv") and self.prv != None: |
| 469 | try: |
| 470 | return self.prv.encrypt(plaintext) |
| 471 | except Exception as e: |
| 472 | RNS.log("The GROUP destination could not encrypt data", RNS.LOG_ERROR) |
| 473 | RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR) |
| 474 | else: |
| 475 | raise ValueError("No private key held by GROUP destination. Did you create or load one?") |
| 476 | } |
| 477 | */ |
| 478 | |
| 479 | // CBA Reference implementation does not handle this default case |
| 480 | // CBA TODO Determine of returning plaintext is appropriate here (for now it's necessary for PROOF packets) |
| 481 | return data; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | Decrypts information for ``RNS.Destination.SINGLE`` or ``RNS.Destination.GROUP`` type destination. |
nothing calls this directly
no outgoing calls
no test coverage detected