GpgFrontend::GpgBasicOperator Class Reference

Basic operation collection. More...

`#include <GpgBasicOperator.h>`

Inheritance diagram for GpgFrontend::GpgBasicOperator:
Collaboration diagram for GpgFrontend::GpgBasicOperator:

## Public Member Functions

| GpgBasicOperator (int channel=SingletonFunctionObject::GetDefaultChannel())
| Construct a new Basic Operator object. More...
gpg_error_t | Encrypt (KeyListPtr keys, BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, GpgEncrResult &result)
| Call the interface provided by gpgme for encryption operation. More...
gpg_error_t | EncryptSymmetric (BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, GpgEncrResult &result)
| Call the interface provided by GPGME to symmetrical encryption. More...
gpgme_error_t | EncryptSign (KeyListPtr keys, KeyListPtr signers, BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, GpgEncrResult &encr_result, GpgSignResult &sign_result)
| Call the interface provided by gpgme to perform encryption and signature operations at the same time. More...
gpgme_error_t | Decrypt (BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, GpgDecrResult &result)
| Call the interface provided by gpgme for decryption operation. More...
gpgme_error_t | DecryptVerify (BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, GpgDecrResult &decrypt_result, GpgVerifyResult &verify_result)
| Call the interface provided by gpgme to perform decryption and verification operations at the same time. More...
gpgme_error_t | Verify (BypeArrayRef in_buffer, ByteArrayPtr &sig_buffer, GpgVerifyResult &result) const
| Call the interface provided by gpgme for verification operation. More...
gpg_error_t | Sign (KeyListPtr signers, BypeArrayRef in_buffer, ByteArrayPtr &out_buffer, gpgme_sig_mode_t mode, GpgSignResult &result)
| Call the interface provided by gpgme for signing operation. More...
void | SetSigners (KeyArgsList &signers)
| Set the private key for signatures, this operation is a global operation. More...
std::unique_ptr< KeyArgsList > | GetSigners ()
| Get a global signature private keys that has been set. More...
Public Member Functions inherited from GpgFrontend::SingletonFunctionObject< GpgBasicOperator >
| SingletonFunctionObject (const SingletonFunctionObject< GpgBasicOperator > &)=delete
| prohibit copy More...
| SingletonFunctionObject (GpgBasicOperator &&)=delete
| Construct a new Singleton Function Object object. More...
| SingletonFunctionObject (const GpgBasicOperator &)=delete
| Construct a new Singleton Function Object object. More...
SingletonFunctionObject & | operator= (const SingletonFunctionObject< GpgBasicOperator > &)=delete
| prohibit copy More...
void | operator= (const GpgBasicOperator &)=delete
int | GetChannel () const
| Get the Channel object. More...
Public Member Functions inherited from GpgFrontend::ChannelObject
| ChannelObject () noexcept
| Construct a new Default Channel Object object. More...
| ChannelObject (int channel)
| Construct a new Channel Object object. More...
int | GetChannel () const
| Get the Channel object. More...
void | SetChannel (int channel)
| Set the Channel object. More...

## Private Attributes

GpgContext & | ctx_
| Corresponding context. More...

## Additional Inherited Members

Static Public Member Functions inherited from GpgFrontend::SingletonFunctionObject< GpgBasicOperator >
static GpgBasicOperator & | GetInstance (int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
| Get the Instance object. More...
static GpgBasicOperator & | CreateInstance (int channel, std::function< std::unique_ptr< ChannelObject >(void)> factory)
| Create a Instance object. More...
static void | ReleaseChannel (int channel)
static int | GetDefaultChannel ()
| Get the Default Channel object. More...
static std::vector< int > | GetAllChannelId ()
| Get all the channel ids. More...
Static Public Member Functions inherited from GpgFrontend::ChannelObject
static int | GetDefaultChannel ()
| Get the Default Channel object. More...
Protected Member Functions inherited from GpgFrontend::SingletonFunctionObject< GpgBasicOperator >
| SingletonFunctionObject ()=default
| Construct a new Singleton Function Object object. More...
| SingletonFunctionObject (int channel)
| Construct a new Singleton Function Object object. More...
virtual | ~SingletonFunctionObject ()=default
| Destroy the Singleton Function Object object. More...

## Detailed Description

Basic operation collection.

## Constructor & Destructor Documentation

## GpgBasicOperator()

GpgFrontend::GpgBasicOperator::GpgBasicOperator | ( | int | channel = `SingletonFunctionObject::GetDefaultChannel()` | ) |

explicit

Construct a new Basic Operator object.

Parameters

  channel | Channel corresponding to the context

Copyright (C) 2021 Saturneric

This file is part of GpgFrontend.

GpgFrontend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

GpgFrontend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GpgFrontend. If not, see https://www.gnu.org/licenses/.

The initial version of the source code is inherited from the gpg4usb project, which is under GPL-3.0-or-later.

All the source code of GpgFrontend was modified and released by Saturnericeric@.nosp@m.bktu.nosp@m.s.com starting on May 12, 2021.

SPDX-License-Identifier: GPL-3.0-or-later

## Member Function Documentation

## Decrypt()

GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Decrypt | ( | BypeArrayRef | in_buffer,
|  | GpgFrontend::ByteArrayPtr & | out_buffer,
|  | GpgFrontend::GpgDecrResult & | result
| ) |  |

Call the interface provided by gpgme for decryption operation.

Parameters

  in_buffer | data that needs to be decrypted
  out_buffer | decrypted data
  result | the result of the operation

Returns
  error code

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::DecryptFile(), and GpgFrontend::UI::MainWindow::slot_decrypt().

## DecryptVerify()

gpgme_error_t GpgFrontend::GpgBasicOperator::DecryptVerify | ( | BypeArrayRef | in_buffer,
|  | ByteArrayPtr & | out_buffer,
|  | GpgDecrResult & | decrypt_result,
|  | GpgVerifyResult & | verify_result
| ) |  |

Call the interface provided by gpgme to perform decryption and verification operations at the same time.

Parameters

  in_buffer | data to be manipulated
  out_buffer | data resulting from decryption operation
  decrypt_result | the result of the decrypting operation
  verify_result | the result of the verifying operation

Returns
  error code

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::DecryptVerifyFile(), and GpgFrontend::UI::MainWindow::slot_decrypt_verify().

## Encrypt()

GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Encrypt | ( | KeyListPtr | keys,
|  | GpgFrontend::BypeArrayRef | in_buffer,
|  | GpgFrontend::ByteArrayPtr & | out_buffer,
|  | GpgFrontend::GpgEncrResult & | result
| ) |  |

Call the interface provided by gpgme for encryption operation.

All incoming data pointers out_buffer will be replaced with new valid values

Parameters

  keys | list of public keys
  in_buffer | data that needs to be encrypted
  out_buffer | encrypted data
  result | the result of the operation

Returns
  error code

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::EncryptFile(), and GpgFrontend::UI::MainWindow::slot_encrypt().

## EncryptSign()

gpgme_error_t GpgFrontend::GpgBasicOperator::EncryptSign | ( | KeyListPtr | keys,
|  | KeyListPtr | signers,
|  | BypeArrayRef | in_buffer,
|  | ByteArrayPtr & | out_buffer,
|  | GpgEncrResult & | encr_result,
|  | GpgSignResult & | sign_result
| ) |  |

Call the interface provided by gpgme to perform encryption and signature operations at the same time.

Parameters

  keys | List of public keys
  signers | Private key for signatures
  in_buffer | Data for operation
  out_buffer | Encrypted data
  encr_result | Encrypted results
  sign_result | Signature result

Returns

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::EncryptSignFile(), and GpgFrontend::UI::MainWindow::slot_encrypt_sign().

## EncryptSymmetric()

gpg_error_t GpgFrontend::GpgBasicOperator::EncryptSymmetric | ( | BypeArrayRef | in_buffer,
|  | ByteArrayPtr & | out_buffer,
|  | GpgEncrResult & | result
| ) |  |

Call the interface provided by GPGME to symmetrical encryption.

Parameters

  in_buffer | Data for encryption
  out_buffer | Encrypted data
  result | Encrypted results

Returns
  gpg_error_t

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::EncryptFileSymmetric(), and GpgFrontend::UI::MainWindow::slot_encrypt().

## GetSigners()

std::unique_ptr< GpgFrontend::KeyArgsList > GpgFrontend::GpgBasicOperator::GetSigners | ( |  | ) |

Get a global signature private keys that has been set.

Returns
  Intelligent pointer pointing to the private key list

## SetSigners()

void GpgFrontend::GpgBasicOperator::SetSigners | ( | KeyArgsList & | signers | ) |

Set the private key for signatures, this operation is a global operation.

Parameters

  keys |

References GpgFrontend::check_gpg_error().

Referenced by GpgFrontend::GpgKeyManager::SignKey().

## Sign()

GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Sign | ( | KeyListPtr | signers,
|  | BypeArrayRef | in_buffer,
|  | ByteArrayPtr & | out_buffer,
|  | gpgme_sig_mode_t | mode,
|  | GpgSignResult & | result
| ) |  |

Call the interface provided by gpgme for signing operation.

The signing modes are as follows: ‘GPGME_SIG_MODE_NORMAL’ A normal signature is made, the output includes the plaintext and the signature. ‘GPGME_SIG_MODE_DETACH’ A detached signature is made. ‘GPGME_SIG_MODE_CLEAR’ A clear text signature is made. The ASCII armor and text mode settings of the context are ignored.

Parameters

  signers | private keys for signing operations
  in_buffer | data that needs to be signed
  out_buffer | verified data
  mode | signing mode
  result | the result of the operation

Returns
  error code

References GpgFrontend::_new_result(), GpgFrontend::check_gpg_error(), and GpgFrontend::GpgData::Read2Buffer().

Referenced by GpgFrontend::GpgFileOpera::SignFile(), and GpgFrontend::UI::MainWindow::slot_sign().

## Verify()

GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Verify | ( | BypeArrayRef | in_buffer,
|  | ByteArrayPtr & | sig_buffer,
|  | GpgVerifyResult & | result
| ) |  | const

Call the interface provided by gpgme for verification operation.

Parameters

  in_buffer | data that needs to be verified
  out_buffer | verified data
  result | the result of the operation

Returns
  error code

References GpgFrontend::_new_result(), and GpgFrontend::check_gpg_error().

Referenced by GpgFrontend::UI::MainWindow::slot_verify(), and GpgFrontend::GpgFileOpera::VerifyFile().

## Member Data Documentation

## ctx_

GpgContext& GpgFrontend::GpgBasicOperator::ctx_

private

Initial value:
= GpgContext::GetInstance(
SingletonFunctionObject::GetChannel())

Corresponding context.

The documentation for this class was generated from the following files:

- src/core/function/gpg/GpgBasicOperator.h
- src/core/function/gpg/GpgBasicOperator.cpp

GpgFrontend::SingletonFunctionObject< GpgContext >::GetInstance
static GpgContext & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:170
GpgFrontend::SingletonFunctionObject::GetChannel
int GetChannel() const
Get the Channel object.
Definition: GpgFunctionObject.h:239