> For the complete documentation index, see [llms.txt](https://docs.medcrypt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.medcrypt.com/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-secureoperation.md).

# medcrypt::guardian::SecureOperation

Named standalone operation.

`#include <SecureOperation.h>`

## Public Functions

|                                                                                                                               | Name                                                                                                                                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                               | <p><a href="#function-~secureoperation"><strong>\~SecureOperation</strong></a>()<br>The destructor.</p>                                                                                                                                                        |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-sign"><strong>Sign</strong></a>(const char <em>in\_data, const size\_t & in\_data\_size, char</em> out\_signature, size\_t \* io\_signature\_size)<br>Create signature.</p>                                                              |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-verify"><strong>Verify</strong></a>(const char <em>in\_data, const size\_t & in\_data\_size, const char</em> in\_signature, const size\_t & in\_signature\_size, bool \* out\_is\_verified)<br>Verify existing signature.</p>            |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-signaturemultipartinit"><strong>SignatureMultipartInit</strong></a>(const bool & in\_force =true)<br>Prepare for multipart sign/verify.</p>                                                                                              |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-signaturemultipartupdate"><strong>SignatureMultipartUpdate</strong></a>(const char \* in\_data, const size\_t & in\_data\_size)<br>Add data to multipart sign/verify operation.</p>                                                      |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-signaturemultipartsignfinal"><strong>SignatureMultipartSignFinal</strong></a>(char <em>out\_signature, size\_t</em> io\_signature\_size)<br>Create signature from previously provided data.</p>                                          |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-signaturemultipartverifyfinal"><strong>SignatureMultipartVerifyFinal</strong></a>(const char <em>in\_signature, const size\_t & in\_signature\_size, bool</em> out\_is\_verified)<br>Verify signature from previously provided data.</p> |

## Public Functions Documentation

### function \~SecureOperation

```cpp
~SecureOperation()
```

The destructor.

**Parameters**:

* **none**

**Return**: none

The destructor will return the contained object to the main [Guardian](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-guardian.md) Run thread.

### function Sign

```cpp
Status Sign(
    const char * in_data,
    const size_t & in_data_size,
    char * out_signature,
    size_t * io_signature_size
)
```

Create signature.

**Parameters**:

* **in\_data** binary data buffer
* **in\_data\_size** bytes in in\_data
* **out\_signature** binary data buffer
* **io\_signature\_size** provide size of out\_signature buffer, on return is set to size of the data in out\_signature or the required size of out\_signature

**Returns**:

* **OK** out\_signature populated with the signature
* **FAIL** general failure, check the log
* **BADPARAM** a provided parameter is nullptr or a size is 0
* **MISCONFIGURED** this secure operation is not configured for signatures
* **OUTOFMEMORY** out\_signature is too small, see io\_signature\_size for required size

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Signature created based on loaded profile.

### function Verify

```cpp
Status Verify(
    const char * in_data,
    const size_t & in_data_size,
    const char * in_signature,
    const size_t & in_signature_size,
    bool * out_is_verified
)
```

Verify existing signature.

**Parameters**:

* **in\_data** binary data buffer
* **in\_data\_size** bytes in in\_data
* **in\_signature** binary data buffer
* **in\_signature\_size** bytes in in\_signature
* **out\_is\_verified** true if in\_data matches in\_signature

**Returns**:

* **OK** signature checked against data, see out\_is\_verified for if signature matched the data
* **FAIL** general failure
* **BADPARAM** a provided parameter is nullptr or a size is 0
* **MISCONFIGURED** this secure operation is not configured for signatures

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Verification based on loaded profile.

Note: return value will be OK for a successful verify operation even if the signature does not match the data. Check out\_is\_verified to see if the data and signature match.

### function SignatureMultipartInit

```cpp
Status SignatureMultipartInit(
    const bool & in_force =true
)
```

Prepare for multipart sign/verify.

**Parameters**:

* **in\_force** optional parameter, true will start a new operation even if another is already in progress

**Returns**:

* **OK** secure operation is ready for data to sign/verify
* **FAIL** general failure
* **MISCONFIGURED** this secure operation is not configured for signatures
* **DENIED** another secure operation is already in progress

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Initializes secure operation for a multipart signature or multipart signature verification.

### function SignatureMultipartUpdate

```cpp
Status SignatureMultipartUpdate(
    const char * in_data,
    const size_t & in_data_size
)
```

Add data to multipart sign/verify operation.

**Parameters**:

* **in\_data\_size** bytes in in\_data
* **in\_data** binary data buffer

**Returns**:

* **OK** data added successfully
* **FAIL** general failure
* **BADPARAM** in\_data is nullptr or in\_data\_size is 0
* **DENIED** this secure operation has not been initialized for a multipart sign/verify operation

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Add data in full or chunked pieces to the secure operation, finish the process with one of the Complete functions.

### function SignatureMultipartSignFinal

```cpp
Status SignatureMultipartSignFinal(
    char * out_signature,
    size_t * io_signature_size
)
```

Create signature from previously provided data.

**Parameters**:

* **io\_signature\_size** provide size of out\_signature buffer, on return is set to size of the data in out\_signature or the required size of out\_signature
* **out\_signature** binary data buffer

**Returns**:

* **OK** out\_signature populated with the signature
* **FAIL** general failure
* **BADPARAM** out\_signature is nullptr or io\_signature\_size is nullptr or 0
* **DENIED** multipart signature has not been intiailzed
* **OUTOFMEMORY** out\_signature is too small, see io\_signature\_size for required size

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

### function SignatureMultipartVerifyFinal

```cpp
Status SignatureMultipartVerifyFinal(
    const char * in_signature,
    const size_t & in_signature_size,
    bool * out_is_verified
)
```

Verify signature from previously provided data.

**Parameters**:

* **in\_signature\_size** bytes in in\_signature
* **in\_signature** binary data buffer
* **out\_is\_verified** true if in\_data matches in\_signature

**Returns**:

* **OK** out\_verified reflects if signature matched the data
* **FAIL** general failure
* **BADPARAM** in\_signature or out\_is\_verified is nullptr or in\_signature\_size is 0
* **DENIED** no data has been added to this secure operation

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.medcrypt.com/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-secureoperation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
